Friday, June 12, 2020

Python tkinter to detect key event

Python exercise to detect key event, for Python3 + tkinter run on Raspberry Pi OS

import tkinter as tk

def key_fun(event):
    print(event)
    key_press = event.keysym
    print(key_press)

command = tk.Tk()
command.bind_all('<Key>', key_fun)
command.mainloop()


No comments: