kbhit/getch python equivalent
woooee at gmail.com
woooee at gmail.com
Mon Apr 22 16:30:50 EDT 2013
> I'm looking for a kbhit/getch equivalent in python in order to be able to stop my inner loop in a controlled way (communication with external hardware is involved and breaking it abruptly may cause unwanted errors
A curses example
import curses
stdscr = curses.initscr()
curses.cbreak()
stdscr.keypad(1)
stdscr.addstr(0,10,"Hit 'q' to quit ")
stdscr.refresh()
key = ''
while key != ord('q'):
key = stdscr.getch()
stdscr.addch(20,25,key)
stdscr.refresh()
curses.endwin()
More information about the Python-list
mailing list