You use a game library for this and then it becomes as simple as pushing a key handler onto the event loop and usually the keycodes are already processed for you as well. I don't get the false dilemma people are creating that somehow this is complicated or that people who use the easy way are less knowledgable than others. If you make a game engine from scratch by yourself it's going to be a logical disaster, whether you've learned c++ or python.
Yeah, it's surprisingly simple. It took little time with a game library to get the key polling to work. I was experimenting with chorded keyboard ideas back then.