Arkadaşlar ben tkinter ile işletim sistemine benzer bir şey yapıyorum, keyboard modülünü kullanıyorum.
İstediğim şey şu;
esc tuşuna bastığımda pencereyi kapatması.
import keyboard
import pyautogui
import tkinter
from tkinter import*
from PIL.ImageTk import PhotoImage
root = Tk()
root.minsize("1920","1080")
root.overrideredirect(1)
simge1 = PhotoImage(file="5.png")
def menü():
menü = Frame(root, bg="#303030")
menü.place(x=0, y=510, height=520, width=350)
gizle = Button(menü, text="Gizle", bg="#191919", fg="white",activeforeground="#F6B737", activebackground="#191919", highlightbackground="#F6B737", command=menü.destroy)
gizle.place(x=233, y=480, height=40, width=60)
çıkış = Button(menü, text="Kapat", bg="#191919", fg="white",activeforeground="#F6B737", activebackground="#191919", highlightbackground="#F6B737", command=exit)
çıkış.place(x=291, y=480, height=40, width=60)
#altçubuk
görev_cubuğu = Frame(root,bg="#191919")
görev_cubuğu.place(x=0, y=1030, height=50, width=1920)
menu = Button(görev_cubuğu, text="F", bg="#191919", fg="white", activebackground="#191919",image=simge1, highlightbackground="#191919", command=menü)
menu.place(x=0, y=0,height=50,width=60)
root.mainloop()