2
# show a character <strong class="highlight">key</strong> when pressed without using Enter <strong class="highlight">key</strong>
3
# hide the Tkinter GUI window, only console shows
13
"""shows <strong class="highlight">key</strong> or tk code for the <strong class="highlight">key</strong>"""
14
if event.keysym == 'Escape':
16
if event.char == event.keysym:
17
# normal number and letter characters
18
print( 'Normal Key %r' % event.char )
19
elif len(event.char) == 1:
20
# charcters like []/.,><#$ also Return and ctrl/key
21
print( 'Punctuation Key %r (%r)' % (event.keysym, event.char) )
23
# f1 to f12, shift keys, caps lock, Home, End, Delete ...
24
print( 'Special Key %r' % event.keysym )
28
print( "Press a key (Escape key to exit):" )
29
root.bind_all('<Key>',key)
30
# don't show the tk window