# # Python single-character input example # import msvcrt # windows console I/O et al. while 1: # if you want to do something while waiting # for a key press, activate the following # while loop: as soon as kbhit() returns true # the getch() call willnot block # while not msvcrt.kbhit(): # # do something "in the background" c = msvcrt.getch(); # get a keypress (no enter needed) print 'c is ', c; # echo the keypress if c == 'q': # check for our exit condition break; print 'Done.'