Is there a way to do key listeners in python without a huge bloated module such as pygame?
An example would be, when I pressed the a key it would print to the console
The a key was pressed!
It should also listen for the arrow keys/spacebar/shift key.
It’s unfortunately not so easy to do that. If you’re trying to make some sort of text user interface, you may want to look into
curses. If you want to display things like you normally would in a terminal, but want input like that, then you’ll have to work withtermios, which unfortunately appears to be poorly documented in Python. Neither of these options are that simple, though, unfortunately. Additionally, they do not work under Windows; if you need them to work under Windows, you’ll have to use PDCurses as a replacement forcursesor pywin32 rather thantermios.I was able to get this working decently. It prints out the hexadecimal representation of keys you type. As I said in the comments of your question, arrows are tricky; I think you’ll agree.