[Tutor] getting input from keyboard

alan.gauld@bt.com alan.gauld@bt.com
Thu Dec 26 07:10:01 2002


> How do I get keyboard input in python ?
> I want to do the equivalent of this C code, in python
> x=getch()

Assuming you are on Windows you need to import mscvrt
and use the getch() function in there.

If you are on Unix you use the curses(or ncurses) module 
which also has a getch() function.

> With the books that I have, there are no references in the 
> index  to get, keyboard input, or in the Python help file.

My online web tutor (and book!)has a topic on event driven 
programming which includes an example of using msvcrt.getch()

Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld