Answers:
其他人提到过xev
,当您运行X11时,这很好。但是,当您在控制台上时,showkey
就是您想要的。
而且,如果您正在SSH会话或真实终端上,则可以使用/usr/lib/ncurses/examples/demo_altkeys
(可在Debian中的ncurses-examples软件包中找到)。
showkey
由于没有获取文件描述符而引起的错误(例如@anatolytechtonik的评论),请尝试sudo showkey
xev
报告扫描代码,而showkey
默认情况下报告密钥代码。sudo showkey -s
报告扫描码。
也是screenkey,它是一个截屏工具,显示在屏幕上按下的键。
有xev
用于图形模式的程序。xev的人在这里http://linux.die.net/man/1/xev
在ubuntu / debian上,它打包成x11-utils
软件包。
chris@retina:~$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ bcm5974 id=13 [slave pointer (2)]
⎜ ↳ Logitech Unifying Device. Wireless PID:1028 id=9 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Power Button id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ FaceTime HD Camera (Built-in) id=11 [slave keyboard (3)]
↳ Apple Inc. Apple Internal Keyboard / Trackpad id=12 [slave keyboard (3)]
↳ daskeyboard id=10 [slave keyboard (3)]
↳ daskeyboard id=14 [slave keyboard (3)]
chris@retina:~$ xinput test 14
key release 36
key press 43
hkey release 43
key press 26
ekey release 26
key press 46
lkey release 46
key press 46
lkey release 46
key press 32
okey release 32
key press 37
key press 54
^C
chris@retina:~$
showkey
在前面的答案中已经提到过。
-a
很有用,显示了如何使用该命令。但是,然后应该发表评论。
sudo showkey -a
ssh也可以。
您也可以使用evtest
。在某些情况下,xev
即使已捕获密钥,也比显示密钥更好。
要在ubuntu / mint下安装sudo apt-get install evtest
。
运行sudo evtest
并选择设备编号。
输出示例:
$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: Lid Switch
/dev/input/event1: Power Button
/dev/input/event2: Power Button
/dev/input/event3: AT Translated Set 2 keyboard
/dev/input/event4: ETPS/2 Elantech Touchpad
/dev/input/event5: Logitech Logitech G930 Headset
/dev/input/event6: Video Bus
/dev/input/event7: HDA Intel HDMI HDMI/DP,pcm=8
/dev/input/event8: HDA Intel HDMI HDMI/DP,pcm=7
/dev/input/event9: HDA Intel HDMI HDMI/DP,pcm=3
/dev/input/event10: HDA Intel PCH Headphone
/dev/input/event11: HDA Intel PCH Mic
/dev/input/event12: WebCam SC-10HDP12B24N
/dev/input/event13: ELAN Touchscreen
Select the device event number [0-13]: 5
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x46d product 0xa1f version 0x101
Input device name: "Logitech Logitech G930 Headset"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 114 (KEY_VOLUMEDOWN)
Event code 115 (KEY_VOLUMEUP)
Event code 163 (KEY_NEXTSONG)
Event code 164 (KEY_PLAYPAUSE)
Event code 165 (KEY_PREVIOUSSONG)
Event code 256 (BTN_0)
Event code 257 (BTN_1)
Event code 258 (BTN_2)
Event code 259 (BTN_3)
Event code 260 (BTN_4)
Event code 261 (BTN_5)
Event code 262 (BTN_6)
Event code 263 (BTN_7)
Event code 264 (BTN_8)
Event code 265 (BTN_9)
Event type 4 (EV_MSC)
Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)
Event: time 1412585327.807585, type 4 (EV_MSC), code 4 (MSC_SCAN), value c00b5
Event: time 1412585327.807585, type 1 (EV_KEY), code 163 (KEY_NEXTSONG), value 1
Event: time 1412585327.807585, -------------- SYN_REPORT ------------
Event: time 1412585327.927557, type 4 (EV_MSC), code 4 (MSC_SCAN), value c00b5
Event: time 1412585327.927557, type 1 (EV_KEY), code 163 (KEY_NEXTSONG), value 0
Event: time 1412585327.927557, -------------- SYN_REPORT ------------
/dev/input
。
xev | grep 'keycode'
state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
state 0x4, keycode 52 (keysym 0x7a, z), same_screen YES,
state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
state 0x0, keycode 54 (keysym 0x63, c), same_screen YES,
state 0x0, keycode 52 (keysym 0x7a, z), same_screen YES,
state 0x0, keycode 54 (keysym 0x63, c), same_screen YES,
xev -event keyboard
仅报告键盘事件。