showkey - examine the scan codes and keycodes sent by the keyboard


showkey [ -hsk --help --scancodes --keycodes ]


showkey prints to standard output either the scan codes or the keycode of each key pressed. The program runs until 10 seconds has elapsed since the last key press or release event, or until it receives a suitable signal, like SIGTERM, from another process.

showkey has two modes of operation, scancode and keycode dumping, selected by a command line option (see below). When in scancode dump mode, it prints in hexadecimal format each byte received from the keyboard to the standard output. A new line is printed when an interval of about 0.1 seconds occurs between the bytes received, or when the internal receive buffer fills up. This can be used to determine roughly, what byte sequences the keyboard sends at once on a given key press. The scan code dumping mode is primarily intended for debugging the keyboard driver or other low level interfaces. As such it shouldn't be of much interest to the regular end-user.

When in the default keycode dump mode, showkey prints to the standard output the keycode number or each key pressed or released. The kind of the event, press or release, is also reported. Keycodes are numbers assigned by the kernel to each individual physical key. Every key has always only one associated keycode number, whether the keyboard sends single or multiple scan codes when pressing it. Using showkey in this mode, you can find out what numbers to use in your personalized keymap files.


-h --help
showkey prints to the standard error output its version number, a compile option and a short usage message, then exits.

-s --scancodes
Starts showkey in scan code dump mode.

-k --keycodes
Starts showkey in keycode dump mode. This is the default, when no command line options are present.


A kernel bug (still present in version 0.99pl14m) causes key releases to be reported as key presses (when in keycode dump mode).


loadkeys (1), dumpkeys (1), keytables (5)