[英]python: how to listen for mouse clicks and keypress at the same time
我想创建一个程序,如果用户按下 shift 和 button-1(左键单击),则会弹出一个 GUI。 但是,我只能使用 pynput 分别监听按键和鼠标点击。 有没有办法同时听这两件事?
这是简单的解决方案:
https://github.com/boppreh/mouse
https://github.com/boppreh/keyboard
import mouse
import keyboard
import time
while True:
if mouse.is_pressed(button='left') and keyboard.is_pressed('shift'):
print("Left mouse button and shift is pressed")
time.sleep(0.5)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.