kbhit() and getch() question
Jeremy Reed
jp_reed at yahoo.com
Thu Mar 8 05:21:37 EST 2001
More information about the Python-list mailing list
Thu Mar 8 05:21:37 EST 2001
- Previous message (by thread): kbhit() and getch() question
- Next message (by thread): kbhit() and getch() question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In a previous question, I asked how to get non-blocking input from the user.
The answer proposed is as follows:
import msvcrt
ch = 0
while ch != 'x':
if msvcrt.kbhit():
ch = msvcrt.getch()
print ch
I have run into a few problems. First of all, the kbhit() doesn't seem to
work. I am unable to find a way for the function to return true.
Second, the getch() function is listed in the documentation as a blocking
call, but it doesn't block when i run it in the following script.
ch = 0
while ch != 'x':
ch = mscvrt.getch()
print ch
Instead, it prints the equivalent to chr(255) in an infinite loop.
Is there some setup call or initialization function that I'm neglecting to
call? Why aren't these function working like the documentation says they
should?
- Previous message (by thread): kbhit() and getch() question
- Next message (by thread): kbhit() and getch() question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list