I hope you are talking about Tkinter as GUI. This code might help you. You have to use a if statements to get the right key value to go to the proper function then.
# bind and show a key event with Tkinter
from Tkinter import *
root = Tk()
prompt = ' Press any key '
label1 = Label(root, text=prompt, width=len(prompt))
label1.pack()
def key(event):
if event.char == event.keysym:
msg = 'Normal Key %r' % event.char
elif len(event.char) == 1:
msg = 'Punctuation Key %r (%r)' % (event.keysym, event.char)
else:
msg = 'Special Key %r' % event.keysym
label1.config(text=msg)
label1.bind_all('<Key>', key)
root.mainloop()
bumsfeld
Nearly a Posting Virtuoso
1,445 posts since Jul 2005
Reputation Points: 404
Solved Threads: 184