需要使用第三方库, 代码如下:
import tkinter as tk
import keyboard
def output(event):
#print("From global keystroke")
print(event)
root = tk.Tk()
root.withdraw()
keyboard.add_hotkey('ctrl+a', output, args=('From global keystroke',))
#keyboard.add_hotkey('ctrl+a', output)
root.mainloop()
标签:global,ctrl,python,keystroke,热键,keyboard,output,全局,root
From: https://www.cnblogs.com/huzhongqiang/p/17647033.html