While this is the obvious approach I can't tell you more because I never needed something like that. Perhaps I have to learn how to do something like that too.
However, I recommend Pygame because it can detect keypress. But how to do it... Don't know. We have Pygame tutorials here, thanks to @metulburr. Take a look
However, I recommend Pygame because it can detect keypress. But how to do it... Don't know. We have Pygame tutorials here, thanks to @metulburr. Take a look