How can I know both the Key c and Ctrl on the keyboard are pressed?

Gabriel Genellina gagsl-py at yahoo.com.ar
Tue Jan 30 18:20:41 CET 2007


En Tue, 30 Jan 2007 05:50:29 -0300, <tidegenerator at tom.com> escribió:

> How can I know the Key c and Ctrl on the keyboard are pressed? Or how
> to let the program press the
>
> key Ctrl+c automatically? I just want to use python to develop a
> script program.
> gear

If you are on Windows and want to trap the Ctrl-C combination, just catch  
the KeyboardInterrupt exception:

--- cut ---
 from time import sleep

while 1:
   try: sleep(1)
   except KeyboardInterrupt: print "Ctrl-C pressed"
--- cut ---

-- 
Gabriel Genellina




More information about the Python-list mailing list