[Tutor] How to capture 'Ctrl+c' in Python
pyro9219 at gmail.com
Fri Nov 3 08:31:35 CET 2006
Nevermind, I just realised my problem with the script I just sent.
I'm using a laptop right now and the print screen key is FN+ Insert.... FN
Works fine on an external keyboard, so I guess I'll try one of the other
Thanks alot for the time guys.
On 11/2/06, Chris Hengge <pyro9219 at gmail.com> wrote:
> I'm not sure where I got this from, but I think its from your site..
> import msvcrt
> def doKeyEvent(key):
> if key == '\x00' or key == '\xe0': # non ASCII
> key = msvcrt.getch() # fetch second character
> print ord(key)
> def doQuitEvent(key):
> raise SystemExit
> # First, clear the screen of clutter then warn the user
> # of what to do to quit
> lines = 25 # set to number of lines in console
> for line in range(lines): print
> print "Hit space to end..."
> # Now mainloop runs "forever"
> while True:
> ky = msvcrt.getch()
> length = len(ky)
> if length != 0:
> # send events to event handling functions
> if ky == " ": # check for quit event
> On 11/2/06, Alan Gauld <alan.gauld at btinternet.com> wrote:
> > "Chris Hengge" <pyro9219 at gmail.com> wrote
> > > Do you by chance know of a way to capture special keys like "Print
> > > Screen"?
> > Try the key capture code in my Event Driven topic.
> > So far as I know it works for all keys including the special ones.
> > It also points out that those keys have a two part code...
> > --
> > Alan Gauld
> > Author of the Learn to Program web site
> > http://www.freenetpages.co.uk/hp/alan.gauld
> > _______________________________________________
> > Tutor maillist - Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor