how to read the arrow keys in python code example
Example: how to get arrow key input in python
import tkinter as tk
def key(event):
"""shows key or tk code for the key"""
if event.keysym == 'Escape':
root.destroy()
if event.char == event.keysym:
print( 'Normal Key %r' % event.char )
elif len(event.char) == 1:
print( 'Punctuation Key %r (%r)' % (event.keysym, event.char) )
else:
print( 'Special Key %r' % event.keysym )
root = tk.Tk()
print( "Press a key (Escape key to exit):" )
root.bind_all('<Key>', key)
root.withdraw()
root.mainloop()