[Tutor] Python 3.0

Alan Gauld alan.gauld at btinternet.com
Sat Feb 20 16:51:37 CET 2010

"Paul Whittaker" <paul.whittaker20 at ntlworld.com> wrote

> Using the following script, the (Windows 7) PC echoes the key presses but
> doesn't quit (ever!)
> import msvcrt
> print('Press SPACE to stop...')
> while True:
>    k = msvcrt.getch()     # Strangely, this echoes to the IDLE window

You will need to run it in an OS command window not in IDLE.
Idle does its own keystoke capturing since its a GUI.

I'll need to add a note to my tutor page to emphasise that since
its probably not intuitively obvious! :-)

Alan G. 

More information about the Tutor mailing list