I've been trying to program a "press any key to continue" function, simply because raw_input feels noobish, but so far I haven't been having much luck.
I did a search and the opinions are nearly unanimous that getch() is the way to go, but...things haven't gone that well. Here's an example of what happens:
from msvcrt import getch
while 1:
keyPressed = getch()
print keyPressed
if keyPressed == "x":
break
The output of running this seemingly harmless program? An infinite loop, even after pressing "x". What's more, getch() seems to pick up the "enter" keystroke to execute this, long after I've lifted the key.
What this looks like to me --and I could be wrong-- is that keystrokes are stored in a stack or list of some sort, and the "Enter" keystroke is on the top of that. It seems that getch() reads the top entry, but *does not remove it*, causing that keystroke to be read for eternity.
I checked both the Python docs and the module docs for info on msvcrt to try to find a way to clear the "enter" keystroke and move on to the next one, but I found utterly nothing. At all.
Anyone know how it's done?