24

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?

5 Answers 5

23

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.

1
  • Exactly what I was thinking for! And when I press the key, nothing shoes... maybe a Virtualbox bug? Jun 15, 2010 at 13:51
23

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.

6

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.

1
  • 1
    Any advice for when neither sudo hexdump /dev/input/by-path/*-kbd nor sudo hexdump /dev/input/event* has any output? My laptop keyboard works in BIOS but nowhere else. I can see output from the aforementioned commands only with my USB keyboard.
    – wpcarro
    Jul 31, 2019 at 11:06
0

There is showkey, which in Ubuntu is installed by default as part of the "kbd" package.

sudo showkey

(It exits after 10 seconds without a key being pressed, or with Ctrl-C)

There is also a quite complete list of possibilities in this answer on "Unix & Linux"

0

If you're using libinput:

  1. Identify keyboard's input stream with sudo libinput list-devices, sample output (look into Kernel: value):
Device:           AT Translated Set 2 keyboard
Kernel:           /dev/input/event3
  1. Debug keyboard with the following command (note --show-keycodes parameter): sudo libinput debug-events --show-keycodes /dev/input/event3

Example output:

-event3   DEVICE_ADDED            AT Translated Set 2 keyboard      seat0 default group1  cap:k
 event3   KEYBOARD_KEY            +2.327s       KEY_KP1 (79) pressed
1 event3   KEYBOARD_KEY            +2.415s      KEY_KP1 (79) released
 event3   KEYBOARD_KEY            +3.901s       KEY_1 (2) pressed
1 event3   KEYBOARD_KEY            +3.989s      KEY_1 (2) released
 event3   KEYBOARD_KEY            +4.632s       KEY_2 (3) pressed
2 event3   KEYBOARD_KEY            +4.720s      KEY_2 (3) released
 event3   KEYBOARD_KEY            +5.022s       KEY_3 (4) pressed

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .