Keyboard configuration in console
Keyboard mappings (keymaps) for virtual console, console fonts and console maps are provided by the package (a dependency of systemd), which also provides many low-level tools for managing virtual console. In addition, systemd also provides the localectl tool, which can control both the system locale and keyboard layout settings for both the virtual console and Xorg.
Viewing keyboard settings
localectl status to view the current keyboard configurations.
Setting keyboard layout
Usually one keymap file corresponds to one keyboard layout (the
include statement can be used to share common parts and a keymap file can contain multiple layouts with some key combination used for switching). The keymap files are stored in the
/usr/share/kbd/keymaps/ directory tree.
The naming conventions of console keymaps are somewhat arbitrary, but usually they are based on:
- Language codes: where the language code is the same as its country code (e.g.
defor German, or
- Country codes: where variations of the same language are used in different countries (e.g.
ukfor United Kingdom English, or
usfor United States English); a list of country codes can also be found in wikipedia:ISO 3166-1#Officially assigned code elements.
- Keyboard layouts: where the layout is not related to a particular country or language (e.g.
dvorakfor the Dvorak keyboard layout).
For a list of all the available keymaps, use the command:
$ localectl list-keymaps
To search for a keymap, use the following command, replacing
search_term with the code for your language, country, or layout:
$ localectl list-keymaps | grep -i search_term
Alternatively, using find:
$ find /usr/share/kbd/keymaps/ -type f
A persistent keymap can be set in
/etc/vconsole.conf, which is read by systemd on start-up. The
KEYMAP variable is used for specifying the keymap. If the variable is empty or not set, the
us keymap is used as default value. See
man 5 vconsole.conf for all options. For example:
For convenience, localectl may be used to set console keymap. It will change the
KEYMAP variable in
/etc/vconsole.conf and also set the keymap for current session:
$ localectl set-keymap --no-convert keymap
--no-convert option can be used to prevent
localectl from automatically changing the Xorg keymap to the nearest match. See
man localectl for more information.
It is possible to set a keymap just for current session. This is useful for testing different keymaps, solving problems etc.
The loadkeys tool is used for this purpose, it is used internally by systemd when loading the keymap configured in
/etc/vconsole.conf. It can be used very simply for this purpose:
# loadkeys keymap
man 1 loadkeys details.
Adjusting typematic delay and rate
The typematic delay indicates the amount of time (typically in miliseconds) a key needs to be pressed and held in order for the repeating process to begin. After the repeating process has been triggered, the character will be repeated with a certain frequency (usually given in Hz) specified by the typematic rate. These values can be changed using the kbdrate command. Note that these settings are configured seperately for the virtual console and for Xorg.
# kbdrate [-d delay] [-r rate]
For example to set a typematic delay to 200ms and a typematic rate to 30Hz, use the following command:
# kbdrate -d 200 -r 30
Issuing the command without specifying the delay and rate will reset the typematic values to their respective defaults; a delay of 250ms and a rate of 11Hz:
A systemd service can be used to set the keyboard rate. For example
[Unit] Description=Keyboard repeat rate in tty. [Service] Type=oneshot RemainAfterExit=yes StandardInput=tty StandardOutput=tty ExecStart=/usr/bin/kbdrate -s -d 450 -r 60 [Install] WantedBy=multi-user.target
Then start/enable the
kbdrate.service systemd service.