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 on a daily basis, the way the keyboard responds makes the difference between typing smoothly and ending up desperate. Key repeat time, initial delay, and the behavior of each key They can be adjusted with enormous precision, both from the graphical environment and from the text console and 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 layout, redefine special keys, change the layout, and even assign advanced actions , the launch programs or turn off the system.

Graphical configuration of key repeat time in Linux

On most modern Linux desktops (e.g., GNOME, KDE Plasma, Cinnamon, etc.), the first place to adjust key behavior is the system settings panel. These environments offer a specific Keyboard section where the delay and repetition rate are adjusted. without fighting with the console.

In a GNOME-type environment, the usual thing to do is to go to “System settings → Keyboard → Key repeat”There are two main controls: the delay before a key starts repeating when held down, and the repetition speed (how many characters are generated per second).

The “repeat delay” controls the time that elapses from when you hold down the key until it starts firing characters nonstop. If you have trouble lifting your finger quickly or if you use the keyboard to move cursors preciselyYou might be interested in increasing that delay, or simply disabling automatic repeat.

The “repeat rate” indicates how many characters are produced once the repetition has started. A high speed can be very useful for scrolling quickly in text or games.But it can also cause you to miss too many characters if you go overboard with the value.

In the specific case of special keys, such as a volume wheel or knob integrated into the keyboardYou 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 scancodeThat scancode reaches the kernel, which transforms it into a keycodeFrom there, a keyboard map is applied that ultimately produces a character or an action.

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

Most keys generate two codes: one when you press them (make code) and another when you release them (break code). In practice, the kernel usually ignores break codes to simplify handlingexcept in specific cases such as toggle keys (Shift, Ctrl, Alt, etc.). In addition, 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 = scancodeIn other ranges (for example 0x59-0x7F or sequences starting with 0xE0), the relationship is not so trivial and an internal kernel table is used that defines which keycode corresponds to each combination of scancodes.

With tools like showkey y getkeycodes You can see exactly what codes your keyboard is producing. For example, by running showkey -k In a virtual console (not a graphical terminal) you will see the keycodes generated by each keystroke, and with showkey -s You can see the raw scancodes sent by the hardware, and it helps troubleshoot problems like when The laptop keyboard does not work.

  Find out how to Pace Up Android Cellphone Utilizing Developer Choices

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, it can be used setkeycodes to adjust the association between scancode and keycode. This command allows you to tell the kernel "when you see this scancode, treat it as if it were this keycode".

The basic syntax is:

setkeycodes scancode keycode

El scancode It is expressed in hexadecimal (for example e049) And the keycode in decimal (for example 112This way you can reassign unconventional keys so that the system sees them as standard keys or other keys that interest you.

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

setkeycodes e049 112

After that 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 converts the keycode into a concrete action.From there, on your map you can decide what keycode 112 does.

To inspect which keycodes the system recognizes and which ranges it supports, you can use getkeycodeswhich will display the internal tables. These utilities usually require administrator privileges because They modify the global behavior of the keyboard in all virtual consoles..

keyboard layout and advanced configuration in Linux

Linux console operating modes

In text consoles (the typical TTYs that 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 doesn't 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 over the keyboard.

MEDIUMRAW mode (Keycode mode)The kernel converts scancodes into keycodes, but doesn't go any further. The application receives keycodes and decides what to doThis 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 it, scancodes are converted to keycodes and then to characters according to an 8-bit keyboard map (usually based on ISO-8859-1). This is the most common way when working directly in TTY with shell.

UNICODE mode (UTF-8)Similar to the previous one, 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 want to support different alphabets or extended symbols.

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

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

Terminal model and terminfo database

Linux inherits a classic concept from UNIX: The system views each session as a type of terminalwhich has certain well-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 database. terminfo, usually located in /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).

  How to fix the “Your connection is not private” error on your PC or mobile phone

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

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

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

settermThis command allows you to modify console attributes, such as video behavior, flickering, colors, and more. If run without arguments, it typically lists all the features that can be adjusted in the current terminal.

tputIt 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 specification Linux Standard Base (LSB)The 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, the steps to initialize the hardware, networks, consoles, and, of course, the keyboard are defined.

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

Regarding the text console keyboard, many distributions use a configuration file such as /etc/sysconfig/keyboardIt specifies key parameters, including the keyboard map to be loaded at startup and 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 y KBD_DELAY: define the repetition frequency (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 run the kbdrate command at startup, you must set both values..

Additionally, there are initial key state settings such as NumLock, ScrollLock and CapsLockThese settings can be set to "yes", "no", or "BIOS" (respect the BIOS configuration). There's even an option to disable the 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 the 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 to manipulate the keyboard in real time. These are console utilities that, when used wisely, allow you to adapt the keyboard to almost any need..

showkeyThis is used to check which codes the keyboard actually generates. showkey -s You see the scancodes exactly as they come from the hardware; with showkey -k The keycodes produced by the kernel routine after the first conversion are shown.

loadkeys: Loads a new keyboard map in virtual consoles. Requires root privileges and should be used with caution, as It affects all TTYs, including the login TTY.A misconfigured map can make it very difficult to enter a password or even log in.

dumpkeysThis allows you to inspect the current keyboard layout and other related details, such as function definitions, character compositions, and symbolic equivalencies. With options such as dumpkeys –long-info, dumpkeys –funcs-only o dumpkeys –compose-only You can get very detailed listings of how your map is structured.

kbdrateIt is the direct tool for changing the repetition rate and initial keyboard delayOn many systems, the default values ​​mimic the IBM keyboard standard: about 10 characters per second and about 250 ms of latency. With kbdrate you can alter these without restarting, and it's useful for understanding accessibility options such as 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 Mark the delay (in milliseconds) and -r the repetition rate (characters per second). If you want a generally slower performance, increase the delay or lower the rate.And if you want something almost instantaneous, you reduce the delay to 200 ms or even less, depending on what your hardware allows.

  How to identify and manage the codecs required for files in Windows

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 a default configuration in files such as /etc/defkeymap.map. Each distribution usually includes map collections 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 for the same 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 …

El numerous It is the internal identifier of the key (keycode), which can be expressed in decimal, octal, or hexadecimal. 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 usually used; instead, symbolic constants that remain stable across kernel versions are employed.

Modifiers are treated as bits of 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 decided by adding up the weights of the active modifiers and consulting the corresponding column. in the definition of that key.

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 taken..

There is also a special mark, the sign + The letters preceding some symbols indicate that they should be treated as letters, meaning 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 don't want a specific key combination to do anything, use the keyword Void SymbolFor example, to make a key only produce 'a' without modifiers and nothing when certain combinations are used, definitions could be used 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, they also include other elements important to the overall behavior. This allows for modularity, support for different character sets, and the definition of function keys and accent combinations..

Directive includes It 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 line keymaps defines which columns (modifier indices) are specified in the map. Instead of listing all 256 possible columns, ranges are usually specified, such as keymaps 0-2,4-5,8,12, which means that columns 0,1,2,4,5,8 and 12 are used (normal, Shift, AltGr, Control, Control+Shift, Alt and Control+Alt). If this line is missing, it is assumed that there are definitions from 0 to M, with M being the maximum index found. in the keycode lines.

character set definitions They are made with lines of the type:

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 They 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”