Wait for a keypress before continuing?
John Doe
jdoe at usenetlove.invalid
Tue Aug 16 17:59:32 EDT 2011
Tim Roberts <timr probo.com> wrote:
> John Doe <jdoe at usenetlove.invalid> wrote:
>
>>def wait_for_keystroke():
>> char=0 while not (char==chr(27) or char==chr(110)):
>> char=msvcrt.getch() if char==0:
>> return
>>
>>That freezes the process.
>
> That exact code works perfectly for me. The function returns as
> soon as I press the escape key. You are running this from a
> console process, and not a GUI process, right?
No. I am running this from within Windows, all sorts of Windows.
So... Does that mean I will need something complex like a keyboard
hook? Or what?
Thanks.
--
>
>>That means char=msvcrt.getch() is getting something?
>
> Did you ever think about inserting a debug statement to help you?
> print hex(ord(char))
More information about the Python-list
mailing list