Keybind that binds to every key in tkinter Keybind that binds to every key in tkinter tkinter tkinter

Keybind that binds to every key in tkinter


I use <Key> it will capture any keyboard event and print "Hello". And don't forget to specify event or event=None parameter in testing() .

from tkinter import *window = Tk()root = Canvas(window, width=500, height=500)def testing(event):    print("Hello!")def countdown(count, label):    label['text'] = count    if count > -1:        root.after(1000, countdown, count-1, label)    elif count == 0:        label['text'] = 'Time Expired'    elif count < 0:        label.destroy()root.bind_all('<Key>', testing)root.pack()root.mainloop()