LOADKEYS(1)

๐Ÿ’– loadkeys โ€” load keyboard translation tables ๐Ÿ’–

okay bestie, sit down, hydrate, because this is the little utility from the kbd family that decides what your keyboard actually means when you smash it. it's giving main character energy for your entire console. let's go ๐Ÿซถ


โœจ SYNOPSIS โœจ

loadkeys [OPTION]... FILENAME...
loadkeys --default
loadkeys --mktable
loadkeys --bkeymap
loadkeys --tkeymap[=shape]
loadkeys --parse

๐ŸŒธ DESCRIPTION ๐ŸŒธ

so basically loadkeys reads the file (or files!) you hand it in FILENAME.... its whole ~purpose~ in life is loading the kernel keymap for your console. you can point it at a specific console device with the -C option (or --console, same vibe).


๐ŸŽ€ RESET TO DEFAULT ๐ŸŽ€

if you pass -d (or --default), loadkeys loads a default keymap โ€” probably the file defkeymap.map, living either in /usr/share/kbd/keymaps or in /usr/src/linux/drivers/tty/vt. (probably the first one was user-defined, while the second is a qwerty keyboard map for PCs โ€” which might not be what you wanted, lowkey ๐Ÿ˜ญ)

sometimes, when you've got a strange keymap loaded (like, the minus key is on some obscure unknown modifier combo and you're just ๐Ÿงš suffering), it's way easier to type:

loadkeys defkeymap.map

๐Ÿ‘‘ LOAD KERNEL KEYMAP ๐Ÿ‘‘

the main function of loadkeys is loading or modifying the keyboard driver's translation tables. when you're listing file names, standard input can be denoted by a dash (-). and if you specify no file at all? the data gets read from standard input. periodt.

for lots of countries and keyboard types, appropriate keymaps already exist, so something like:

loadkeys uk

might just do the thing you want โœจ. on the other hand, constructing your own keymap is easy. the user has to tell what symbols belong to each key. she can find the keycode for a key using showkey(1), while the keymap format is given in keymaps(5) and can also be seen from the output of dumpkeys(1). iykyk ๐Ÿ’…


๐Ÿฆ‹ LOAD KERNEL ACCENT TABLE ๐Ÿฆ‹

if your input file contains no compose key definitions, the kernel accent table is left untouched โ€” unless you give the -c option (or --clearcompose), in which case the kernel accent table gets emptied. empty. gone. bye ๐Ÿซถ

if your input file does contain compose key definitions, then all the old definitions get removed and replaced by the new entries you specified. the kernel accent table is a sequence of entries (68 by default!) describing how dead diacritical signs and compose keys behave. for example, a line like:

compose ',' 'c' to ccedilla

means that <ComposeKey><,><c> must be combined to <ccedilla>. you can peek at the current content of this table with:

dumpkeys --compose-only

๐Ÿ“ LOAD KERNEL STRING TABLE ๐Ÿ“

the -s option (or --clearstrings) clears the kernel string table. if you don't give this option, loadkeys will only add or replace strings โ€” it will not remove them. (so yeah, the -s option is required to reach a well-defined state, fr fr.)

the kernel string table is a sequence of strings with names like F31. you can make function key F5 (on an ordinary PC keyboard) produce the text Hello!, and Shift+F5 produce Goodbye!, using lines like:

keycode 63 = F70 F71
string F70 = "Hello!"
string F71 = "Goodbye!"

in the keymap. the default bindings for the function keys are certain escape sequences, mostly inspired by the VT100 terminal. iconic behavior honestly.


๐ŸŒˆ CREATE KERNEL SOURCE TABLE ๐ŸŒˆ

if you give the -m option (or --mktable), loadkeys prints to standard output a file that may be used as /usr/src/linux/drivers/tty/vt/defkeymap.c, specifying the default key bindings for a kernel. and heads up โ€” it does not modify the current keymap. slay, no side effects ๐Ÿ’…


โญ CREATE BINARY KEYMAP โญ

if you give the -b option (or --bkeymap), loadkeys prints to standard output a file that may be used as a binary keymap, exactly as expected by the Busybox loadkmap command. and again โ€” it does not modify the current keymap. ๐Ÿ˜Œ


๐Ÿ’œ CREATE TEXT KEYMAP ๐Ÿ’œ

if you give the -t option (or --tkeymap), loadkeys prints to standard output a file that may be used as a text keymap, as expected by the loadkeys command itself. and yes โ€” it does not modify the current keymap.

you can also hand it an optional argument to pick the shape of the output format: -tshape (or --tkeymap=shape).

the available shapes are:

  • 2 โ€” default output.
  • 4 โ€” one line for each keycode.
  • 8 โ€” one line for each (modifier,keycode) pair.
  • 16 โ€” one line for each keycode until the 1st hole.

๐Ÿงš UNICODE MODE ๐Ÿงš

loadkeys automatically detects whether the console is in Unicode or ASCII (XLATE) mode. when a keymap is loaded, literal keysyms (such as section) are resolved accordingly; numerical keysyms are converted to fit the current console mode, regardless of the way they are specified (decimal, octal, hexadecimal or Unicode). no cap.

the -u switch (or --unicode) forces loadkeys to convert all keymaps to Unicode. if the keyboard is in a non-Unicode mode, such as XLATE, loadkeys will change it to Unicode for the time of its execution. a warning message will be printed in this case. โš ๏ธ

it is recommended to run kbd_mode(1) before loadkeys instead of using the -u option.

๐Ÿ’… OTHER OPTIONS ๐Ÿ’…

  • -a, --ascii โ€” force conversion to ASCII.
  • -h, --help โ€” loadkeys prints its version number and a short usage message to the program's standard error output and exits.
  • -p, --parse โ€” loadkeys searches and parses the keymap without taking any action.
  • -q, --quiet โ€” loadkeys suppresses all normal output. shhh ๐Ÿคซ
  • -V, --version โ€” loadkeys prints the version number and exits.

๐Ÿ’€ WARNING ๐Ÿ’€

okay bestie this part is important, read it twice.

anyone with read access to /dev/console can run loadkeys and therefore change the keyboard layout โ€” possibly making it unusable. ๐Ÿ˜ญ and note that the keyboard translation table is common for all the virtual consoles, so any changes to the keyboard bindings affect all the virtual consoles simultaneously.

also, because the changes affect all the virtual consoles, they outlive your session. which means that even at the login prompt, the key bindings may not be what the user expects. no takebacks, no undo, it's giving permanent ๐Ÿ˜ณ


๐Ÿ“ FILES ๐Ÿ“

  • /usr/share/kbd/keymaps โ€” default directory for keymaps.
  • /usr/src/linux/drivers/tty/vt/defkeymap.map โ€” default kernel keymap.

๐Ÿซถ SEE ALSO ๐Ÿซถ

dumpkeys(1), keymaps(5)


and that's the whole page, bestie โœจ this one's from the kbd fam, dated way back on 6 Feb 1994 โ€” vintage but still absolutely serving in every console you'll ever touch. go forth and remap responsibly ๐ŸŒธ๐Ÿ’–

๐Ÿ“ฆ where this page comes from