I was looking for a list of keyboard scancodes in the linux kernel sources, but I did not find anything. Does someone know where to find these? Especially the USB scancodes would be interesting.
1 Answer
The keycodes are in [src]/drivers/tty/vt/defkeymap.map:
# Default kernel keymap. This uses 7 modifier combinations. [...] See also my answer here for ways to view (dumpkeys) and modify (loadkeys) the current keymap as it exists in the running kernel.
However, those are a bit higher level than the scancodes sent by the device. Those might be what's in the table at the top of [src]/drivers/hid/hid-input.c, however, since they come from the device, you don't need the linux kernel source to find out what they are; they are the same regardless of OS.
"HID" == human interface device. The usbhid subdirectory of drivers/hid doesn't appear to contain any special codes, since USB keyboards are really regular keyboards.
One difference between keycodes and scancodes is that scancodes are more granular -- notice there's a different signal for the press and release. A keycode corresponds to a key that's down, I believe; so the kernel maps scancode events to a keycode status.
- Okay, that seems to be what I was looking for, thanks. But I still miss the actual scancode, probably I just mix up things. I learned here that when I press ENTER on my USB keyboard, the scancode
1Cis sent to the kernel. But I don't seem to find1Cin/drivers/tty/vt/defkeymap.map. Is there another layer between them?defoe– defoe2013-11-28 15:02:16 +00:00Commented Nov 28, 2013 at 15:02 - Whoops, I confused keycodes and scancodes -- have edited that in. Decimal
28is hexadecimal1C.goldilocks– goldilocks2013-11-28 15:23:04 +00:00Commented Nov 28, 2013 at 15:23 - ...notice
1Cis the IBM PC XT "Return pressed" from that wikipedia link.goldilocks– goldilocks2013-11-28 15:27:27 +00:00Commented Nov 28, 2013 at 15:27
/include/uapi/linux/input.hbut it does not contain the actual keycodes.