how to stop a loop with ESC key? [newbie]

Fredrik Lundh fredrik at pythonware.com
Tue Nov 8 11:11:18 CET 2005


"mo" <WYWAL_TOmich202 at o2.pl> wrote:

> I tryed your example:
>
> import msvcrt
> while 1:
>    print '.'
>    if msvcrt.kbhit() and msvcrt.getch() == chr(27):
>         break
>
> but it doesn't work. It is running (Win2000), there is no messages about
> errors but there is no effect when pressing ESC key. What I am doing wrong?

works for me, when running it from a stock CPython interpreter in a windows
console window, with focus set to that window.

what environment are you using?

</F> 






More information about the Python-list mailing list