0

I'm creating a simple console application in python and I'd like to replicate the shell functionally where pressing the up or down key lets you cycle through previous commands.

I can easily store a list of previous commands but the hard part is catching up and down key presses. I have read that you can do this using a ui library like Qt but this seems overkill for such a simple thing.

Does anybody know of a lightweight and simple way to do this that uses no non standard modules?

jonathan topf
  • 7,897
  • 17
  • 55
  • 85
  • This question has already got an answer here: http://stackoverflow.com/questions/17815686/detect-key-input-in-python – Tamás Sengel Feb 28 '14 at 17:50
  • I wouldn't call it lightweight, but the most obvious way to go would be to try [curses](http://docs.python.org/2/library/curses.html) ([howto](http://docs.python.org/2/howto/curses.html)). – Wojciech Walczak Feb 28 '14 at 17:59

0 Answers0