How to "debug" a keyboard in Linux? Like pressing a key and seeing a code in a terminal
I didn't have an answer to my problem about adding additional keyboards in my Ubuntu 10.04. Questions mark is not working in my keyboard, only using Alt Gr key + W.
So, I don't know if this is a problem with Ubuntu or Virtualbox itself (I'm running it inside a VM).
It's an usb keyboard. HP KU-0316.
I would like to debug this problem. The keyboard is plugged in, so when I press a key I believe something is being sent to my operating system, some code, I don't know. I would like to digg this problem, find some damn key code and find some damn *.conf file and manually fix my problem.
So, do an application like this exist in Linux?
Try xev
. It will display the keycodes that the X Window system sees when you press the keys you're interested in. You can use xmodmap
to modify the mapping.
An awesome utility from linux-input called 'evtest' is excellent at debugging keyboard, mice, and joysticks. Function keys should work too.
apt-get install evtest
Sample output from pressing the caps lock key while evtest running:
Event: time 1398955189.226822, type 17 (EV_LED), code 1 (LED_CAPSL), value 1
Event: time 1398955189.226822, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70039
Event: time 1398955189.226822, type 1 (EV_KEY), code 58 (KEY_CAPSLOCK), value 0
Event: time 1398955189.226822, -------------- SYN_REPORT ------------
Since evtest uses /dev/input, you can use it from a TTY or SSH, with no Xserver running.
There are so-called event device files which are bound into a very low level of input layer. They reside in /dev/input/
directory, and you can read keycodes that are passed by virtual PS/2 keyboard by doing sudo hd /dev/input/by-path/platform-i8042-serio-0-event-kbd
. If this command fails, just try that with each of /dev/input/eventX
files: one of them will be bound to your keyboard.