请先使用 evtest 命令检测是否能获取该按键事件
运行 sudo evtest 然后按序号选择键盘(例如下面的键盘序号是3),
planc0515@uos:~$ sudo evtest
Available devices:
/dev/input/event0: Sleep Button
/dev/input/event1: Power Button
/dev/input/event2: Power Button
/dev/input/event3: SIGMACHIP USB Keyboard
/dev/input/event4: SIGMACHIP USB Keyboard Consumer Control
/dev/input/event5: SIGMACHIP USB Keyboard System Control
/dev/input/event6: PixA琀 USB Optical Mouse
/dev/input/event7: PC Speaker
/dev/input/event8: HDA ATI HDMI HDMI/DP,pcm=3
/dev/input/event9: HDA Intel PCH Rear Mic
/dev/input/event10: HDA Intel PCH Front Mic
/dev/input/event11: HDA Intel PCH Line
/dev/input/event12: HDA Intel PCH Line Out
/dev/input/event13: HDA Intel PCH Front Headphone
/dev/input/event14: 87:48:54:15:83:35
Select the device event number [0-14]:
然后按对应的快捷键,观察是否有正确的事件产生,例如下面这个输出中
code 29 (KEY_LEFTCTRL)表示按键是 [左CTRL]
value 1表示按下,value 0表示松开
Event: time 1597816145.422913, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0
Event: time 1597816145.422913, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1
Event: time 1597816145.422913, -------------- SYN_REPORT ------------
Event: time 1597816145.542865, type 4 (EV_MSC), code 4 (MSC_SCAN), value 700e0
Event: time 1597816145.542865, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 0
Event: time 1597816145.542865, -------------- SYN_REPORT ------------