AutoKey 中的 getkey
getkey in AutoKey
如何使用自动键等待按键按下?
对于 AutoKey,我找到了 wait_for_keypress,但它不是我要搜索的。
等待定义的按键或组合键。
我想等待 a,b,... z 被按下。
我在这里搜索:
并尝试了这个例子的 soe 但没有成功:
Detecting a keypress in python while in the background
Is it still true that with python3 in Windows it is impossible to input a single character from the screen without hitting enter?
我在网上搜索了
autokey -autohotkey keywait manual
以下解决方案仅适用于 root 权限:
sudo apt install python3-pip
pip3 install keyboard
sudo autokey
然后这有效(在 Kubuntu 20.04 中测试,请参阅下面的详细信息):
import keyboard as keyboard2 # must be different name becouse of name conflicts
while True:
key = keyboard2.read_key()
if keyboard2.is_pressed(' '):
keyboard.send_keys("You pressed space")
if key == "p":
break
测试:
Operating System: Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
如何使用自动键等待按键按下?
对于 AutoKey,我找到了 wait_for_keypress,但它不是我要搜索的。
等待定义的按键或组合键。
我想等待 a,b,... z 被按下。
我在这里搜索:
并尝试了这个例子的 soe 但没有成功:
Detecting a keypress in python while in the background
Is it still true that with python3 in Windows it is impossible to input a single character from the screen without hitting enter?
我在网上搜索了
autokey -autohotkey keywait manual
以下解决方案仅适用于 root 权限:
sudo apt install python3-pip
pip3 install keyboard
sudo autokey
然后这有效(在 Kubuntu 20.04 中测试,请参阅下面的详细信息):
import keyboard as keyboard2 # must be different name becouse of name conflicts
while True:
key = keyboard2.read_key()
if keyboard2.is_pressed(' '):
keyboard.send_keys("You pressed space")
if key == "p":
break
测试:
Operating System: Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8