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
doQuitEvent(ky)
else:
doKeyEvent(ky)
On 11/2/06,
Alan Gauld <[EMAIL PROTECTED]> wrote:
"Chris Hengge" <[EMAIL PROTECTED]> 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@python.org
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor