unbuffered input

Gerrit gerrit at nl.linux.org
Thu Feb 5 21:28:04 CET 2004

michael young wrote:
>   I have a numbered menu that I want users to from. They choose the
> number corresponding to the action they wish to take.
> Right now I'm using input() to get the user's responce. They press the
> number then press ENTER. I would like to skip the
> part where they press ENTER, so that the user presses the number and
> then they get the action they chose without having
> to press ENTER. Is there a way to do this and how?

Yes, but it's not really platform-independent.
You can find a way to do this at:


On Windows, you can use the getch() function from the mscvrt module.
On Unix, it is a bit more difficult, but the trick is using tty.setraw.
On Mac, you use the Carbon package.


PrePEP: Builtin path type
Asperger's Syndrome - a personal approach:

More information about the Python-list mailing list