I have a canvas with a rectangle and I want to detect if someone pressed the rectangle together with a key (ie "shift"). In Matplotlib the mouse event can do that with the key
property. Wondering if tkinter has somehting similar? I tried this solution
from tkinter import *
root = Tk()
def key(event):
print("pressed", repr(event.char))
def callback(event):
print("clicked at", event.x, event.y)
canvas= Canvas(root, width=100, height=100)
canvas.bind("<Key>", key)
canvas.bind("<Button-1>", callback)
canvas.pack()
root.mainloop()
but it doesn't detect key events, only the mouseclick events work.