Search code examples
pythonkeyboard-events

Handling keyboard events in python


How can I handle keyboard events in python? More exactly I need to manage keyboard arrows and some other keys for my command-line application. Is there a module for this or I need to handle key by key using for example "if get(key)==(mykey): do something" (it's pseudo-code)? I'm on Gnu/Linux OS.


Solution

  • You're probably looking for a python (n)curses library. This will allow to "get around" your terminal buffering and work with key-presses directly.