1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| import tkinter as tk
root = tk.Tk()
flag_evt = {'ctrl': False, 'toucheA': False}
def on_press(evt):
if evt.keycode == 37:#touche ctrl
flag_evt['ctrl'] = True
elif evt.keycode == 24:#touche "a"
flag_evt['toucheA'] = True
if all(flag_evt[value] for value in flag_evt):
print('Appui touche "a" et Ctrl simultané')
def release(evt):
if evt.keycode == 37:#touche ctrl
flag_evt['ctrl'] = False
elif evt.keycode == 24:
flag_evt['toucheA'] = False
root.bind('<KeyPress>', on_press)
root.bind('<KeyRelease>', release)
root.mainloop() |
Partager