getting keyboard input 1 char at a time
Peter Hansen
peter at engcorp.com
Sun Oct 29 20:09:17 EST 2000
Greg Jorgensen wrote:
>
> "John R Bedal" <jbedal at hotmail.com>:
> > Is there a platform independant method for getting keyboard input one
> > character at a time?
>
> c = sys.stdin.read(1)
>
> There's an example on page 79 of the book "Python Essential Reference."
It's possible John wanted a method which would return "keystrokes", as
opposed to just whatever was in stdin. The above, at least on Win32,
only returns characters that have been entered once the ENTER key is
hit. On win32, he would have to use msvcrt.getch() or something.
I don't think there is a truly platform-independent method, but I'd be
happy to be corrected.
--
Peter Hansen
More information about the Python-list
mailing list