getkeycodes
Show keycode-to-keysym mappings of input devices
SYNOPSIS
getkeycodes
DESCRIPTION
The getkeycodes command is a utility from the kbd package, designed to output the current scancode-to-keycode mapping table maintained by the Linux kernel. When a key is pressed on a keyboard, it sends a hardware-specific scancode. The kernel then translates this scancode into a more abstract keycode, which represents the logical meaning of the key (e.g., "A", "Enter", "F1").
This command provides a diagnostic view of how the kernel interprets these raw hardware signals. It is particularly useful for debugging keyboard issues on the Linux console, for understanding custom key layouts, or for verifying the effects of changes made with the setkeycodes command. The output consists of pairs of hexadecimal scancodes and their corresponding decimal keycodes, offering a direct insight into the low-level keyboard configuration.
CAVEATS
getkeycodes displays the mapping for the console keyboard driver. It does not affect or display the keyboard mapping used within graphical environments like X11 or Wayland, which manage their own input devices and keymaps independently.
This command is purely informational; it reads and prints the current state and does not modify any system settings.
UNDERSTANDING SCANCODES AND KEYCODES
A scancode is a raw value generated by the keyboard hardware when a key is pressed or released. These values are specific to the keyboard's internal design.
A keycode, on the other hand, is a kernel-level representation of a key's logical function, independent of the specific hardware scancode. The kernel uses a mapping table to translate scancodes into keycodes, which are then used by applications. getkeycodes reveals this crucial translation layer.
OUTPUT FORMAT
The output of getkeycodes consists of lines, each containing two numbers separated by a space: the first is the hexadecimal scancode, and the second is its corresponding decimal keycode. For example, "0x1e 48" means that scancode 0x1e (typically 'a') maps to keycode 48.
HISTORY
The getkeycodes command has been a stable part of the kbd (keyboard) utilities for Linux for many years. The kbd project focuses on managing the Linux console's keyboard, fonts, and screen modes. Its purpose as a diagnostic tool for the kernel's scancode-to-keycode mapping has remained consistent since its inception, reflecting the underlying need for a low-level understanding of hardware input on the console.
SEE ALSO
setkeycodes(8), dumpkeys(1), loadkeys(1), showkey(1)