Using msvcrt (in Windows), how to catch Enter key?

Ricardo Aráoz ricaraoz at gmail.com
Mon Oct 29 18:51:10 EDT 2007


Dick Moores wrote:
> Windows XP Pro, Python 2.5.1
> 
> import msvcrt
> while True:
>      if msvcrt.kbhit():
>          key = msvcrt.getch()
>          if key == 'Enter'
> 	 do something
> 
> Is there a way to catch the pressing of the 'Enter' key?
> 
> Thanks,
> 
> Dick Moores
> 

You have examples for this in http://effbot.org/librarybook/msvcrt.htm

HTH





More information about the Python-list mailing list