Linuxリスニングイベント
3199 ワード
キーボード
https://blog.csdn.net/kcp606/article/details/79859024 https://python-evdev.readthedocs.io/en/latest/tutorial.html https://www.jianshu.com/p/5f12b0e9a9e5
私のノートパソコンのキーボード:
https://blog.csdn.net/kcp606/article/details/79859024 https://python-evdev.readthedocs.io/en/latest/tutorial.html https://www.jianshu.com/p/5f12b0e9a9e5
私のノートパソコンのキーボード:
/dev/input/event11
私のUSBキーボード:/dev/input/event10
#!/home/tqc/anaconda3/envs/tf/bin/python
#coding: utf-8
from evdev import InputDevice
from select import select
def detectInputKey():
dev = InputDevice('/dev/input/event10')
print(dev)
print(dev.capabilities(verbose=True))
while True:
print('
')
select([dev], [], [])
for event in dev.read():
print("code:%s value:%s" % (event.code, event.value))
if __name__ == '__main__':
detectInputKey()