[Tutor] How to capture 'Ctrl+c' in Python
Chris Hengge
pyro9219 at gmail.com
Wed Nov 1 21:54:24 CET 2006
Do you by chance know of a way to capture special keys like "Print Screen"?
I have a small script to grab all they keycodes, but it doesn't seem to
catch several keys on the keyboard. I've got a utility that I'd like to be
able to automagically get a screenshot when something goes wrong so I dont
have to hope the user can re-create the error. Universal support would be
best, but WinXP is the main OS.
On 11/1/06, Andreas Kostyrka <andreas at kostyrka.org> wrote:
>
> Am Mittwoch, den 01.11.2006, 10:14 +0000 schrieb Asrarahmed Kadri:
> >
> >
> > Hi folks,
> > How can I know that the user has pressed a particular key or c
> > combination of keys.. for example 'q' or 'Ctrl-c' ....?
>
> In practice that depends upon your environment. Unix/Linux, MacOS,
> Windows, GUI vs. cmdline have all different ways to "read" from the
> keyboard.
>
> Ctrl-c OTOH, usually sends the interrupt signal to the process, and as
> such can caught via the KeyboardInterrupt exception:
>
> try:
> somework
> except KeyboardInterrupt:
> ctrlc_caught
>
> Andreas
>
> >
> > Thanks in anticipation.
> >
> > Regards,
> >
> > Asrarahmed
> >
> >
> >
> > --
> > To HIM you shall return.
> > _______________________________________________
> > Tutor maillist - Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061101/f3356eaa/attachment.htm
More information about the Tutor
mailing list