Skip to contentSkip to conversation

"showkey -s" prints incorrect scan codes

DISCUSSION Vincent Lefevre 2 participants 2 messages Sep 16 – Sep 17

lore
Share & tools
lore
#0 lore raw

Under Debian/unstable (package kbd 2.9.0-1), "showkey -s" prints completely incorrect scan codes, and doesn't even print anything for the Fn key (while evtest does).

This is apparently a known bug:
https://wiki.archlinux.org/title/Keyboard_input

Except from this wiki, I couldn't find any mention of this bug, so this was rather surprising.

Signature · 3 lines
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)
#1 lore raw
Quoted 9 lines · Vincent Lefevre

Under Debian/unstable (package kbd 2.9.0-1), "showkey -s" prints completely incorrect scan codes, and doesn't even print anything for the Fn key (while evtest does).

This is apparently a known bug:
https://wiki.archlinux.org/title/Keyboard_input

Except from this wiki, I couldn't find any mention of this bug, so this was rather surprising.

This is written directly in the man page:

In 2.6 kernels raw mode, or scancode mode, is not very raw at all. Scan codes are first translated to key codes, and when scancodes are desired, the key codes are translated back. Various transformations are involved, and there is no guarantee at all that the final result corresponds to what the keyboard hardware did send. So, if you want to know the scan codes sent by various keys it is better to boot a 2.4 kernel. Since 2.6.9 there also is the boot option atkbd.softraw=0 that tells the 2.6 kernel to return the actual scan codes.

So this is a problem that has been known for a very long time. By saying that, I don't mean that it shouldn't be fixed.

showkey is a very old utility, and I have to admit I had completely forgotten about a feature like getting scancodes. I think I could add support for evdev to get the correct result.

I added the --device={DEV,all} option, which specifies which device to use. If it is an evdev device, a new mechanism for retrieving scancodes will be used. You can simply run:

  ./showkey --device=all --scancodes

Could you try it in the for-master branch ? Does this behavior of the utility seem normal to you?

https://github.com/legionus/kbd/compare/master...refs/heads/for-master

Signature · 1 line
Rgrds, legion