Configure keyboard key repeat time in Linux

Last update: 23/04/2026
Author Isaac
  • Adjusting the key repetition time and speed in Linux can be done both from the graphical environment and with console tools.
  • The system translates scancodes into keycodes and then into characters using keyboard maps, modifiers, and different console modes.
  • Utilities such as kbdrate, setkeycodes, loadkeys and dumpkeys allow for extensive customization of keyboard behavior and special keys.
  • The permanent configuration relies on boot scripts, maps in /usr/share/kbd, and the terminfo database for the terminal model.

Configure key repeat in Linux

When you work with Linux daily, the way your keyboard responds makes all the difference between typing smoothly and getting frustrated. Key repeat time, initial delay, and the behavior of each key can be adjusted with incredible precision, both from the graphical environment and the text console, as well as the kernel itself.

Furthermore, in Linux you can not only change how long it takes for a key to start repeating or how many characters per second it generates when you hold it down, but you can also modify the keyboard map, redefine special keys, change the layout, and even assign advanced actions such as launching programs or shutting down the system.

Graphical configuration of key repeat time in Linux

In most modern Linux desktop environments (e.g., GNOME, KDE Plasma, Cinnamon, etc.), the first place to adjust key behavior is the system settings panel. These environments offer a dedicated Keyboard section where you can adjust key delay and repeat rate without having to deal with the command line.

In a GNOME-like environment, the usual way is to go to “System Settings → Keyboard → Key Repeat” . There you will find two main controls: the delay before a key starts repeating when held down, and the repeat rate (how many characters per second are generated).

The "repeat delay" controls the time that elapses from when you release a key until it starts typing continuously. If you have trouble lifting your finger quickly or if you use the keyboard to move cursors precisely , you might want to increase this delay, or even disable automatic repeat altogether.

The "repeat rate" indicates how many characters are produced once the repetition has started. A high rate can be great for fast scrolling in text or games , but it can also cause you to miss too many characters if you set the value too high.

In the specific case of special keys, such as a volume wheel or knob integrated into the keyboard , you might want different behavior. For example, you might want the volume to go up or down instantly when you turn the wheel, without the typical 600ms delay of other keys. In standard graphical environments, there's usually no option to set a different delay for each key, so that's where the system's lower layer and console utilities come into play.

Adjust key repeat delay and speed

Keyboard control from the system: scancodes, keycodes and BIOS

Beneath the graphical layer, Linux handles the keyboard with far more detail than it might seem. When you press a key, the device doesn't send a letter directly, but rather a scancode . This scancode reaches the kernel, which transforms it into a keycode , and from there a keyboard map is applied that ultimately produces a character or action.

Traditionally, BIOS interrupt 9 handled keyboard input (typical in MS-DOS-like systems), but in Linux, the kernel installs its own keyboard interrupt service routine . This routine follows a similar scheme to the classic one, although with differences in the interpretation of scancodes and how internal buffers are filled.

Most keys generate two codes: one when pressed (make code) and another when released (break code). In practice, the kernel usually ignores break codes to simplify handling , except in specific cases such as toggle keys (Shift, Ctrl, Alt, etc.). Additionally, some special keys generate double sequences: first a prefix byte (for example, 0xE0) and then the key code.

For scancodes in the range 0x01-0x58 (1 to 88 in decimal), Linux applies a very straightforward rule by default: keycode = scancode . In other ranges (for example, 0x59-0x7F or sequences starting with 0xE0), the relationship is not so straightforward, and an internal kernel table is used to define which keycode corresponds to each combination of scancodes.

With tools like `showkey` and `getkeycodes`, you can see exactly what codes your keyboard is producing. For example, running `showkey -k` in a virtual console (not a graphical terminal) will show you the keycodes generated by each keystroke, and with `showkey -s` you can see the raw scancodes sent by the hardware, which helps troubleshoot problems like when your laptop keyboard isn't working.

  Formatting an external drive on macOS: Complete guide to formats and steps

Modify key assignment: setkeycodes command

In situations where a special key (such as a volume wheel, multimedia keys, or extra keys on the keyboard) is not interpreted correctly, you can use `setkeycodes` to adjust the association between scancode and keycode. This command lets you tell the kernel, "When you see this scancode, treat it as if it were this keycode . "

The basic syntax is:

setkeycodes scancode keycode

The scancode is expressed in hexadecimal (for example , e049 ) and the keycode in decimal (for example, 112 ). This allows you to reassign unconventional keys so the system sees them as standard keys or other keys of your choice.

Imagine that your keyboard generates the sequence 0xE0 0x49 when you press a physical "Page Up" key. According to the kernel's default key table, that might correspond to keycode 104. If you'd prefer that key to behave differently, you could run something like:

setkeycodes e049 112

After this change, pressing that key will generate keycode 112 instead of 104. The important thing here is that this reassignment is done at the kernel level, before the keyboard map translates the keycode into a specific action . From there, you can decide what keycode 112 does in your map.

To inspect which keycodes the system recognizes and what ranges it supports, you can use `getkeycodes` , which will display the internal tables. These utilities typically require administrator privileges because they modify the global keyboard behavior across all virtual consoles.

keyboard layout and advanced configuration in Linux

Linux console operating modes

In text-based consoles (the typical TTYs you access with Ctrl+Alt+F1…F6 ), the Linux keyboard and console driver can operate in several modes, which determine exactly what the application receives. These modes influence how scancodes, keycodes, and characters are interpreted.

The main modes are:

RAW mode (Scan mode) : the driver does not translate anything; it sends the scancodes as is to the application. This is the lowest level mode and is typically used when a graphical system or a specialized application wants complete control of the keyboard.

MEDIUMRAW mode (Keycode mode) : The kernel converts scancodes to keycodes, but does nothing more. The application receives the keycodes and decides what to do . This approach is useful for programs that implement their own shortcut and translation system.

XLATE mode (ASCII mode) : This is the traditional default mode in text consoles. In this mode, scancodes are converted to keycodes and then to characters according to an 8-bit keyboard map (usually based on ISO-8859-1). It is the most common mode when working directly in TTY with a shell.

UNICODE (UTF-8) mode : Similar to the previous mode, but using a Unicode character set, sending UTF-8 sequences to the kernel to represent characters larger than one byte. This mode is key in modern systems that need to support different alphabets or extended symbols.

The console's effective mode is related to the TERM environment variable . If you run `printenv TERM` , you'll typically see "linux" in a virtual console, while in a graphical terminal running X or Wayland, you'll see "xterm", "xterm-256color", or something similar. When running an X server, X itself manages the keyboard , and the kernel usually leaves the console in RAW mode, delegating interpretation to the graphical server.

In this context, the Alt key is known as the Meta key, and the Alt+X combination is usually written as MetaX. The behavior of these Meta keystrokes can be adjusted with the setmetamode utility , which allows you to choose whether pressing Alt+X sends an ESC X sequence (escape followed by the character) or a character whose value is X plus 128, that is, with bit 7 set.

Terminal model and terminfo database

Linux inherits a classic concept from UNIX: the system views each session as a type of terminal , which has known characteristics (special keys, color capabilities, cursor control, etc.). Even if you only have a monitor and a keyboard, the kernel sees you as connected through a specific terminal model.

The capabilities of each terminal model are described in the terminfo database , usually located at /usr/share/terminfo/ . This database contains files organized into subdirectories by initial letter (for example, the vt100 file is located in a subdirectory whose name begins with the first letter of the terminal).

Each terminfo file describes the terminal name, alias, and a huge list of capabilities: which escape sequences correspond to the function keys , how the cursor is moved, how lines are cleared , etc. A typical header example for a classic terminal is something like “vt100|vt100-am|dec vt100 (w/advanced video) …”.

  Share My Location Not Engaged on iPhone

To interact with terminal features from the command line, you have several tools:

stty : used to view and adjust terminal parameters (echo, flow control, delete characters, etc.).

`setterm` : allows you to modify console attributes, such as video behavior, blinking, colors, and others. If run without arguments, it usually lists all the features that can be adjusted in the current terminal.

tput : relies on terminfo to send standard control sequences to the terminal, such as clearing the screen, moving the cursor, or changing attributes, without having to manually write the ANSI sequences.

Keyboard configuration at system startup

According to the Linux Standard Base (LSB) specification , system startup scripts reside in /etc/init.d/ and are launched directly or indirectly by /sbin/init , the parent process of all others. Within this structure are defined the steps for initializing hardware, networks, consoles, and, of course, the keyboard.

Typically, during the boot sequence, scripts located in /etc/init.d/boot.d/ or equivalent paths depending on the distribution are executed. These scripts handle elements such as serial ports, network cards, the CMOS clock, logical volumes , and other basic components. Finally, a script like /etc/init.d/boot.local is usually executed for custom administrator commands.

Regarding the text console keyboard, many distributions use a configuration file such as /etc/sysconfig/keyboard . This file specifies key parameters, including the keyboard layout to be loaded at startup and the repeat settings.

That file contains directives such as:

KEYTABLE : indicates the keyboard map file, usually located in /usr/share/kbd/keymaps/ . A typical value might be “es.map.gz”, which points to a map for a Spanish keyboard.

KBD_RATE and KBD_DELAY : These define the repetition rate (for example, from 2.0 to 30.0 characters per second) and the initial delay in milliseconds (250, 500, 750, 1000, etc.). If you want the system to execute the kbdrate command at startup, you must set both values.

Additionally, there are initial state settings for keys like Num Lock, Scroll Lock, and Caps Lock , which can be set to "yes," "no," or "BIOS" (respect the BIOS settings). There's even an option to disable Caps Lock functionality and convert the Caps Lock key into a regular Shift key.

The most important line for the overall behavior of the keyboard is the one that defines the map, something like this:

KEYTABLE="es.map.gz"

This map determines what each keycode does; that is, what character or action will be generated when each key is pressed in combination with modifiers (Shift, AltGr, Control, etc.). From there, you can adjust the behavior on the fly with tools like loadkeys, dumpkeys, showkey, and kbdrate.

Key utilities: showkey, loadkeys, dumpkeys, and kbdrate

Once the system is up and running, you have several powerful tools at your disposal for manipulating the keyboard in real time. These are console utilities that, when used wisely, allow you to adapt the keyboard to almost any need.

`showkey` : This command is used to check which codes the keyboard actually generates. ` showkey -s` displays the scancodes as they come from the hardware; ` showkey -k` displays the keycodes produced by the kernel routine after the first conversion.

`loadkeys` : Loads a new keyboard map into the virtual consoles. It requires root privileges and should be used with caution, as it affects all TTYs, including the login key . A misconfigured map can make typing a password or even logging in extremely difficult.

`dumpkeys` : allows you to inspect the current keyboard layout and other related details, such as function definitions, character compositions, and symbolic equivalencies. With options like `dumpkeys --long-info` , `dumpkeys --funcs-only` , or `dumpkeys --compose-only`, you can obtain very detailed listings of how your keyboard layout is structured.

kbdrate : This is the direct tool for changing the keyboard's repeat rate and initial delay . On many systems, the default values ​​mimic the IBM keyboard standard: about 10 characters per second and about 250 ms of delay. With kbdrate, you can alter these without restarting, and it's useful for understanding accessibility options like filter keys in Windows.

For example, for a very short delay and a fast repetition, you could use something like:

kbdrate -d 200 -r 30

where -d sets the delay (in milliseconds) and -r sets the repetition rate (characters per second). If you want a generally slower response, increase the delay or decrease the rate , and if you want something almost instantaneous, reduce the delay to 200 ms or even less, depending on your hardware.

  Complete Guide to Cancel your Minecraft Realms Subscription

The keyboard map: internal definition and modifiers

The "keymap" or keyboard map is the heart of advanced configuration. These maps can be compiled into the kernel or stored as text files in /usr/share/kbd/keymaps/ , with default configurations in files like /etc/defkeymap.map . Each distribution typically includes collections of maps for different languages ​​and layouts.

Keyboard maps define, using a specific syntax, what each keycode does in combination with various modifiers. Generally speaking, up to 256 different actions can be defined for a single key , associated with the possible combinations of modifiers (Shift, Alt, Control, AltGr, etc.).

The map file uses lines of the following form:

keycode number = symbol symbol symbol …

The number is the key's internal identifier (keycode), which can be expressed in decimal, octal, or hexadecimal. The symbol (keysym) represents the associated action, which can be a character, a sequence of characters, or a special function such as Remove, Boot, Console_15 , and many others. Direct numeric codes are not typically used; instead, symbolic constants that remain stable across kernel versions are employed.

Modifiers are treated as bits in an octet, each with a specific "weight." For example, Shift might have a weight of 1, AltGr a weight of 2, Control a weight of 4, Alt a weight of 8, and so on with Left Shift, Right Shift, Left Control, and Right Control. When you press a key, the effective action is determined by adding the weights of the active modifiers and consulting the corresponding column in that key's definition.

For example, if you press a key with Shift and Alt, the sum might be 9, and the definition in column 9 dictates what will be generated. Without any modifier, the index is 0, and the first symbol defined in the keycode line is used.

There is also a special mark, the + sign before some symbols, which indicates that they should be treated as letters, that is, that they correspond to Caps Lock and Shift. A typical example:

keycode 30 = +a

This indicates that the key generates a lowercase 'a' without modifiers, 'A' if uppercase is used, etc. For more specific behavior, the uppercase column can be explicitly defined, for example:

keycode 30 = +a A

If you want a key to do nothing in a specific combination, you use the keyword VoidSymbol . For example, to make a key only produce 'a' without modifiers and nothing when certain combinations are used, you could use definitions where those cases are marked with VoidSymbol. Furthermore, the syntax allows for simplifications: if a single symbol is defined and it is not an ASCII letter, it is assumed to be replicated in all specified columns.

Other parts of the map: includes, keymaps, charset, functions, and composition

Keyboard map files not only contain keycode definitions, but also include other elements important for overall behavior. This allows for modularity, support for different character sets, and the definition of function keys and accent combinations.

The `include` directive allows you to include other files, similar to an `import`. This is useful for reusing common parts in several maps, for example, an accent table or a set of standard functions.

The `keymaps` line defines which columns (modifier indices) are specified in the map. Instead of listing all 256 possible columns, ranges are typically specified, such as ` keymaps 0-2,4-5,8,12` , meaning that columns 0, 1, 2, 4, 5, 8, and 12 (normal, Shift, AltGr, Control, Control+Shift, Alt, and Control+Alt) are used. If this line is missing, it is assumed that there are definitions from 0 to M, where M is the highest index found in the `keycode` lines.

Character set definitions are done with lines like this:

charset «iso-8859-2»

and determine which code page the numerical values ​​of the characters correspond to. By default, ISO-8859-1 (Latin-1) is usually used, but others, such as ISO-8859-2 or ISO-8859-7, can also be used. This is relevant for symbols such as the Greek letter mu or special characters specific to certain languages.

String definitions use the following syntax:

string keysym = "text"

and are used to associate function keys or special keys with specific character sequences. For example, you can specify that F1 sends “ESC”

Isaac

Isaac

Passionate writer about the world of bytes and technology in general. I love sharing my knowledge through writing, and that's what I'll do on this blog, show you all the most interesting things about gadgets, software, hardware, tech trends, and more. My goal is to help you navigate the digital world in a simple and entertaining way.