SETKEYCODES(8)
โจ SETKEYCODES(8) โจ
System Manager's Manual ๐ธ
๐ NAME ๐
setkeycodes, okay so this one loads kernel scancode-to-keycode mapping table entries ๐
๐ SYNOPSIS ๐
setkeycodes [options] scancode keycode ...
๐ฆ DESCRIPTION ๐ฆ
Okay bestie, so the setkeycodes command reads its arguments two at a time ๐. Each pair is a scancode (written in hexadecimal) followed by a keycode (written in decimal). For every pair, it tells the kernel keyboard driver to map that scancode to that keycode โจ. It's giving precision.
This command is only really useful for people with slightly unusual keyboards ๐. Like, if you have a few keys that send scancodes the kernel doesn't recognize, this is your moment ๐ .
๐ง THEORY ๐ง
Okay so, every key press and key release on a usual PC keyboard sends a little series of scancodes ๐ฅ. (You can peek at those with showkey -s, see showkey(1) ๐.) The kernel reads that stream and turns it into a stream of keycodes, which are the key press and release events ๐. (You can see keycodes with showkey.)
Here's the tea. Apart from a few scancodes with special meaning, the Pause key's sequence, the shiftstate-related scancodes, and the key up/down bit, the stream is made of two flavors: unescaped scancodes xx (7 bits), and escaped scancodes e0 xx (8+7 bits) ๐. Each of these scancodes or scancode pairs can be given a matching keycode, anywhere in the range 1-127 ๐.
Let's say you've got a Macro key that sends e0 6f according to showkey(1). Then this command:
setkeycodes e06f 112
will assign keycode 112 to it ๐ง. After that, loadkeys(1) can be used to decide what the key actually does โจ.
Heads up: some older kernels hardwire a low scancode range to the equivalent keycodes. If you try to remap those, setkeycodes will fail ๐.
๐ซง 2.6 KERNELS ๐ซง
In 2.6 kernels, keycodes live in the range 1-255 instead of 1-127 ๐ธ. (Honestly, it might be safest to stick to 1-239 ๐ซถ.)
Warning, bestie ๐ญ: in 2.6 kernels, raw mode (aka scancode mode) is not very raw at all. The code thatshowkey -sreturns will change after you usesetkeycodes. That's a kernel bug, not you ๐ . See also showkey(1).
๐ OPTIONS ๐
-C,--console=DEVโ pick the console device you want to use ๐ฅ๏ธ-V,--versionโ shows you the version number ๐ข-h,--helpโ shows you the usage message ๐
๐ BUGS ๐
The keycodes of X have nothing to do with the ones in Linux, so no cap, they're not the same ๐. Some unusual keys can be made visible under Linux, but not under X ๐ญ.
๐ SEE ALSO ๐
dumpkeys(1), loadkeys(1), showkey(1), getkeycodes(8) ๐
Source: kbd, 24 October 2024. Stay iconic, bestie ๐๐โจ
๐ฆ 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
- debian trixie: kbd 2.7.1-2 ยท 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
- ubuntu questing: kbd 2.7.1-2ubuntu1 ยท GPL-2.0-or-later
- ubuntu resolute: kbd 2.7.1-2ubuntu2 ยท GPL-2.0-or-later
- ubuntu stonking: kbd 2.9.0-1ubuntu1 ยท GPL-2.0-or-later
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms