Wait for a keypress before continuing?
Tim Roberts
timr at probo.com
Sun Aug 21 22:02:56 EDT 2011
John Doe <jdoe at usenetlove.invalid> wrote:
>
>Tim Roberts <timr probo.com> wrote:
>
>> 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?
I see that this conversation took a nasty turn while I was on vacation.
msvcrt.getch works with consoles. If you have an application where stdin
and stdout are connected to a real, live console window (which looks just
like a command line window), then msvcrt.getch will work. If not, then you
have to use the Windows APIs. GetKeyboardState and GetKeyState can tell
you if a specific key is currently being pressed.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list