Off-Topic Discussion > Programming

Python raw input/keyboard polling


I'm working on a small personal project that requires python (something technically similar to this) and I would like to use raw unbuffered keybord input to control it.
What I would ideally like would be a method that returns a set of key codes for all keys being pressed on the system, (again ideally) redirects all keyboard input to it so it doesn't print to the terminal, and (while I'm making unreasonable demands) you can specify which keyboard on the system it will attach to.
This will be on a Raspberry pi (original model B) running the latest Raspian. There is no need to worry about portability.

any ideas? Python is not a language I have used much.

What library are you using to handle input?

Nothing at the momemt, so far I've just been focusing on the output, I've started looking into termios, but the main goal of this thread is figuring out what to use.

There are at least as many different ways to handle input in Python as there are libraries to choose from; usually you pick something that handles both input and output (e.g. pyglet), but you can probably find something solely for raw input if you want.

well this is going to be running in a headless environment, so output would be at best useless and at worse a source of failure. so that's why I have been avoiding all inclusive game apis.


[0] Message Index

Go to full version