SHOWKEY(1)
๐ NAME ๐
showkey โ bestie, this one is literally just here to examine the codes sent by the keyboard. That's it. That's the whole job. โจ
๐ SYNOPSIS ๐
showkey [-h|--help] [-a|--ascii] [-s|--scancodes] [-k|--keycodes]
[-V|--version]
๐ฆ DESCRIPTION ๐ฆ
okay so showkey prints to standard output either the scan codes or the keycode or the ascii code of every single key you press. pick your fighter, basically. ๐
In the first two modes โ that's scancodes and keycodes, iykyk โ the program just keeps vibing until 10 seconds have gone by since the last key press or release event, or until it catches a suitable signal like SIGTERM from some other process. In ascii mode it dips out when you type ^D. byeee ๐ซถ
When you're in scancode dump mode, showkey prints in hexadecimal format each byte it receives from the keyboard, straight to standard output. A new line shows up when an interval of about 0.1 seconds happens between the bytes received, or when the internal receive buffer fills up. So you can use this to figure out roughly what byte sequences the keyboard sends all at once when you hit a given key. The scan code dumping mode is primarily for debugging the keyboard driver or other low level interfaces โ as such it shouldn't be of much interest to the regular end-user, ngl. However. Some modern keyboards have keys or buttons that produce scancodes the kernel doesn't associate a keycode with, and once you find out what those are, you can assign keycodes with setkeycodes(8). slay. ๐ฅ
When you're in the default keycode dump mode, showkey prints to standard output the keycode number of each key pressed or released. The kind of event โ press or release โ gets reported too, because of course it does. Keycodes are numbers the kernel assigns to each individual physical key. Every key always has only one associated keycode number, no matter whether the keyboard sends single or multiple scan codes when you press it. Using showkey in this mode, you can find out what numbers to use in your personalized keymap files. main character energy fr fr ๐
When you're in ascii dump mode, showkey prints to standard output the decimal, octal, and hexadecimal value(s) of the key pressed, according to the present keymap. a whole little trio, obsessed. โจ
๐ OPTIONS ๐
-h,--helpโ showkey prints to the standard error output its version number, a compile option, and a short usage message, then exits. little info dump and then it's gone.-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. no notes, she's the default for a reason ๐-a,--asciiโ starts showkey inasciidump mode.-V,--versionโ showkey prints version number and exits. short, sweet, iconic.
๐ง 2.6 KERNELS ๐ง
In 2.6 kernels key codes lie in the range 1-255, instead of 1-127. Key codes larger than 127 are returned as three bytes, of which the low order 7 bits are: zero, bits 13-7, and bits 6-0 of the key code. The high order bits are: 0/1 for make/break, 1, 1. that's the whole anatomy bestie, don't lose it ๐ฆ
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 actually 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. use it, she's right there ๐
๐ธ AUTHORS ๐ธ
Andries Brouwer <aeb@cwi.nl>
๐ SEE ALSO ๐
loadkeys(1), dumpkeys(1), keymaps(5), setkeycodes(8)
this page is brought to you by the kbd crew, dated 1 Feb 1998 โ yeah bestie she's an elder but she still ate ๐โจ periodt.
๐ฆ where this page comes from
- alpine 3.22: kbd-doc 2.7.1-r1 ยท GPL-2.0-or-later
- alpine 3.23: kbd-doc 2.8.0-r0 ยท GPL-2.0-or-later
- alpine 3.24: kbd-doc 2.8.0-r0 ยท GPL-2.0-or-later
- arch rolling: kbd 2.10.0-1 ยท GPL-2.0-or-later
- nixos 26.05: kbd 2.9.0
- nixos 26.05: kbd-vlock 2.9.0
- nixpkgs unstable: kbd 2.9.0
- nixpkgs unstable: kbd-vlock 2.9.0
- opensuse-leap 16.0: kbd 2.7.1-160000.3.1 ยท GPL-2.0-or-later AND GPL-3.0-or-later
- opensuse-leap 16.0: kbd 2.7.1-160000.3.1 ยท GPL-2.0-or-later AND GPL-3.0-or-later
- opensuse-leap 16.0: kbd 2.7.1-160000.3.1 ยท GPL-2.0-or-later AND GPL-3.0-or-later
- opensuse-leap 16.0: kbd 2.7.1-160000.3.1 ยท GPL-2.0-or-later AND GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms