LinuxCommandLibrary

getkeycodes

Show keycode-to-keysym mappings of input devices

SYNOPSIS

getkeycodes [-hV] [-s] [scancode...]

PARAMETERS

-h, --help
    Display help text and exit

-V, --version
    Display version information and exit

-s
    Suppress printing scancode, show only keycodes

DESCRIPTION

The getkeycodes command is a Linux utility that retrieves and displays the kernel's internal mapping table from hardware scancodes (generated by pressing keys on a keyboard) to Linux keycodes. This 1:1 mapping is crucial for understanding how the kernel interprets keyboard input before higher-level processing by X11, Wayland, or console input systems.

Without arguments, it outputs the entire table, showing scancodes in hexadecimal and their corresponding keycodes in decimal. Specifying one scancode shows only that entry; two scancodes define a range to dump. This tool is invaluable for debugging keyboard issues, such as missing keys on custom or international layouts, or verifying mappings before using companion tools like setkeycodes.

Part of the kbd package, it interacts directly with the kernel via ioctl calls on input devices, typically under /dev/input. Output format is tabular: scancode (hex), keycode (dec), making it easy to parse or pipe to other tools. It's non-interactive and lightweight, ideal for scripts checking console keymaps.

CAVEATS

Read-only operation; use setkeycodes(8) to modify mappings. May require input group permissions for some devices. Output assumes evdev or atkbd drivers.

EXAMPLES

getkeycodes
Dump full table
getkeycodes 1
Show mapping for scancode 0x1
getkeycodes 1 10
Dump range from 1 to 0xa

OUTPUT SAMPLE

scancode keycode
0x01 59 (KEY_ESC)
0x02 1 (KEY_1)

HISTORY

Developed as part of the Linux kbd package by Risto Kankkunen and others in the early 1990s, alongside console tools. Evolved with kernel input layer (evdev in 2.6+), remains essential for low-level keyboard diagnostics.

SEE ALSO

Copied to clipboard