loop until keypress (Windows XP)

Farshid Lashkari no at spam.com
Thu Aug 10 01:31:26 EDT 2006


placid wrote:
> is there a way to do this, wait for user input but dont block?

Hi,

The msvcrt module should do what you want. Here is a sample:

import msvcrt

chr = 0
while chr != 'q':
     """ keep printing text """
     if msvcrt.kbhit():
         chr = msvcrt.getch()


Keep in mind that this will only work on windows.

-Farshid



More information about the Python-list mailing list