Linux keyboard repeat delay

Linux console/Keyboard configuration

Keyboard mappings (keymaps), console fonts and console maps for the Linux console are provided by the kbd package (a dependency of systemd), which also provides many low-level tools for managing text console. In addition, systemd also provides the localectl tool, which can control both the system locale and keyboard layout settings for both the console and Xorg.

Contents

Viewing keyboard settings

Use localectl status to view the current keyboard configurations.

Keymaps

The keymap files are stored in the /usr/share/kbd/keymaps/ directory tree. 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). For more details see keymaps(5) .

Listing keymaps

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. de for German, or fr for French).
  • Country codes: where variations of the same language are used in different countries (e.g. uk for United Kingdom English, or us for 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. dvorak for the Dvorak keyboard layout).

For a list of all the available keymaps, use the command:

To search for a keymap, use the following command, replacing search_term with the code for your language, country, or layout:

Alternatively, using find:

Loadkeys

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:

Persistent configuration

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 vconsole.conf(5) 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:

The —no-convert option can be used to prevent localectl from automatically changing the Xorg keymap to the nearest match. See localectl(1) for more information.

If required, the keymap from /etc/vconsole.conf can be loaded during early userspace by the keymap mkinitcpio hook.

Creating a custom keymap

When using the console, you can use hotkeys to print a specific character. Moreover we can also print a sequence of characters and some escape sequences. Thus, if we print the sequence of characters constituting a command and afterwards an escape character for a new line, that command will be executed.

One method of doing this is editing the keymap file. However, since it will be rewritten anytime the package it belongs to is updated, editing this file is discouraged. It is better to integrate the existing keymap with a personal keymap. The loadkeys utility can do this.

First, create a keymap file. This keymap file can be anywhere, but one method is to mimic the directory hierarchy in /usr/local :

As a side note, it is worth noting that such a personal keymap is useful also to redefine the behaviour of keys already treated by the default keymap: when loaded with loadkeys , the directives in the default keymap will be replaced when they conflict with the new directives and conserved otherwise. This way, only changes to the keymap must be specified in the personal keymap.

Adding directives

Two kinds of directives are required in this personal keymap. First of all, the keycode directives, which matches the format seen in the default keymaps. These directives associate a keycode with a keysym. Keysyms represent keyboard actions. The actions available include outputting character codes or character sequences, switching consoles or keymaps, booting the machine, and many other actions. The full currently active keymap can be obtained with

Most keysyms are intuitive. For example, to set key 112 to output an ‘e’, the directive will be:

To set key 112 to output a euro symbol, the directive will be:

Some keysym are not immediately connected to a keyboard actions. In particular, the keysyms prefixed by a capital F and one to three digits (F1-F246) constituting a number greater than 30 are always free. This is useful directing a hotkey to output a sequence of characters and other actions:

Then, F70 can be bound to output a specific string:

When key 112 is pressed, it will output the contents of F70. In order to execute a printed command in a terminal, a newline escape character must be appended to the end of the command string. For example, to enter a system into hibernation, the following keymap is added:

Читайте также:  Балансировка нагрузки windows 2012

Other examples

  • To make the Right Alt key same as Left Alt key (for Emacs), use the following line in your keymap. It will include the file /usr/share/kbd/keymaps/i386/include/linux-with-two-alt-keys.inc , check it for details.
  • To swap CapsLock with Escape (for Vim), remap the respective keycodes:
  • To make CapsLock another Control key, remap the respective keycode:
  • To swap CapsLock with Left Control key, remap the respective keycodes:

Saving changes

In order to make use of the personal keymap, it must be loaded with loadkeys:

However this keymap is only active for the current session. In order to load the keymap at boot, specify the full path to the file in the KEYMAP variable in /etc/vconsole.conf. The file does not have to be gzipped as the official keymaps provided by kbd .

Adjusting typematic delay and rate

The typematic delay indicates the amount of time (typically in milliseconds) 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 separately for the console and for Xorg.

For example to set a typematic delay to 200ms and a typematic rate to 30Hz, use the following command:

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:

Systemd service

A systemd service can be used to set the keyboard rate. For example:

Источник

How to set keyboard repeat delay and speed in Ubuntu Gnome 16.10?

In previous versions I could tweak the keyboard repeat delay and speed by going to Settings > Keyboard > Typing . Now in Ubuntu Gnome 16.10 (with Gnome 3.20.2) that panel seems to be missing.

How can I configure those settings in this version?

4 Answers 4

These settings are under Settings → Universal AccessTypingRepeat Keys. You have to click the Repeat Keys row item, which brings up a pop-up dialog with two settings: Delay and Speed.

This works in Ubuntu 17.04 and above.

In older versions of Ubuntu, the Speed setting worked in reverse: the lower the speed, the faster the repeat rate. This is no longer the case.

On ubuntu 14.04 and up this will survive after reboot:

If nothing else works, try running xset r rate 220 40 from a console.

For me, the HID layer got broken in some way and config GUI didn’t work, gsettings didn’t work, only xset worked.

This solution however is not persistent — will disappear on restart (unless added to

I’m a Ubuntu 18.04.3 User. and not a techie. I tried changing the kdrate in terminal. I was told it had changed, but it didn’t change the slow keyboard input. This low tech method worked for me. Go to «Show Applications», where there’s a «InputMethod» utility, which has a keyboard as the icon. Open this. ignore the warnings. Select «Yes» then you are presented with a list of options. The one which worked for me is «auto activate IM with @mark for most locales». You need to reboot your PC/laptop. Then you can go to «Settings» «Typing» and then click on «repeat keys» and «cursor blinking». Both these options have sliders which you can use to speed up and slow the keyboard and key strokes. I tried looking at the Keyboard Documentation. I didn’t understand it, so I hope this answer works for Ubuntu users like me.

Источник

Adjusting keyboard sensitivity in a command line terminal?

When using a tty login shell by entering Ctrl-Alt-F1 from an Ubuntu 12.04 install on a laptop the keyboard seems overly sensitive and if my finger lingers for a moment on a button I end up with repeats of the same letter. Is there a way to adjust keyboard sensitivity that would influence the keyboard response when accessing a login shell from a tty instance?

3 Answers 3

(I noticed a complaint that kbdrate might have a max limitation. Not sure how true it still is).

I use xset r rate 250 60 to accomplish speedups to my liking. I happen to put that in my

/.i3/config (for i3wm) but I used to have it working in my

/.xinitrc for startx to pick up. The xset invocation should apply to everything running in X.

(I’d be curious to hear if there’s any reason to prefer kbdrate or xset .)

It is called ‘keyboard auto repeat rate’ and you can set it with kbdrate Mine is set to:

You can set same with:

Check the manual page for exact options:

Unsure where the default setting is done, but /etc/rc.local , your .bash_profile , .profile or .bashrc sounds like a good place.

Add atkbd.softrepeat=1 on the kernel command line if you need fast repeat rate and low delay.

Without the trick, the hardware delay is limited by 250 ms, and the maximum repeat rate is 30. For the most people who use arrows for navigation in text editor or command line, the rate is too low, and the delay is too high.

Meanwhile, in Visual Studio, developers use an option called «double effective keyboard repeat rate» in the Visual Assist plugin. It should be a nice reason for the existence of the option.

Working with Linux without X could be a nice time saver, because you don’t use your browser.

If you’ve spent more than a working day googling how to make kbdrate to accept the slower delay than 250 ms, the answer should help.

Читайте также:  Просмотрщик картинок для mac os

Источник

Xorg/Keyboard configuration

This article describes the basics of Xorg keyboard configuration. For advanced topics such as keyboard layout modification or additional key mappings, see X keyboard extension or Extra keyboard keys respectively.

The Xorg server uses the X keyboard extension (XKB) to define keyboard layouts. Optionally, xmodmap can be used to access the internal keymap table directly, although this is not recommended for complex tasks. Also systemd’s localectl can be used to define the keyboard layout for both the Xorg server and the virtual console.

Contents

Viewing keyboard settings

You can use the following command to see the actual XKB settings:

Third party utilities

There are some «unofficial» utilities which allow to print specific information about the currently used keyboard layout.

Setting keyboard layout

Keyboard layout in Xorg can be set in multiple ways. Here is an explanation of used options:

  • XkbModel selects the keyboard model. This has an influence only for some extra keys your keyboard might have. The safe fallback are pc104 or pc105 . But for instance laptops usually have some extra keys, and sometimes you can make them work by simply setting a proper model.
  • XkbLayout selects the keyboard layout. Multiple layouts may be specified in a comma-separated list, e.g. if you want to quickly switch between layouts.
  • XkbVariant selects a specific layout variant available for the XkbLayout . For instance, the default sk (Slovak) variant is qwertz , but you can manually specify qwerty , etc.
  • XkbOptions contains some extra options (comma-separated). Used for specifying layout switching, notification LED, compose mode etc. See the #Frequently used XKB options section for examples.

The layout name is usually a 2-letter country code. To see a full list of keyboard models, layouts, variants and options, along with a short description, open /usr/share/X11/xkb/rules/base.lst . Alternatively, you may use one of the following commands to see a list without a description:

  • localectl list-x11-keymap-models
  • localectl list-x11-keymap-layouts
  • localectl list-x11-keymap-variants [layout]
  • localectl list-x11-keymap-options

Examples in the following subsections will have the same effect, they will set pc104 model, cz as primary layout, us as secondary layout, dvorak variant for us layout and the Win+Space combination for switching between layouts. See xkeyboard-config(7) for more detailed information.

Using setxkbmap

This article or section needs expansion.

setxkbmap sets the keyboard layout for the current X session only, but can be made persistent in xinitrc or xprofile. This overrides system-wide configuration specified following #Using X configuration files. However, persistence does not apply to keyboards such as external keyboards, unless their device id was specified when setxkbmap was run. Or that they are the core keyboard device of the X server.

The usage is as follows (see setxkbmap(1) ):

To change just the layout ( -layout is the default flag):

For multiple customizations:

Using X configuration files

The syntax of X configuration files is explained in Xorg#Configuration. This method creates system-wide configuration which is persistent across reboots.

Here is an example:

Using localectl

For convenience, the tool localectl may be used instead of manually editing X configuration files. It will save the configuration in /etc/X11/xorg.conf.d/00-keyboard.conf , this file should not be manually edited, because localectl will overwrite the changes on next start.

The usage is as follows:

To set a model, variant or options, all preceding fields need to be specified, but the preceding fields can be skipped by passing an empty string with «» . Unless the —no-convert option is passed, the specified keymap is also converted to the closest matching console keymap and applied to the console configuration in vconsole.conf . See localectl(1) for more information.

To create a /etc/X11/xorg.conf.d/00-keyboard.conf like the above:

Frequently used XKB options

Switching between keyboard layouts

To be able to easily switch keyboard layouts, first specify multiple layouts between which you want to switch (the first one is the default). Then specify a key (or key combination), which will be used for switching. For example, to switch between a US and a Swedish layout using the CapsLock key, use us,se as an argument of XkbLayout and grp:caps_toggle as an argument of XkbOptions . The number of XkbLayout s should match that of the XkbVariant s — if you want to switch solely between different variants, then duplicate the layout accordingly (e.g. de,de ).

You can use other key combinations than CapsLock , they are listed in /usr/share/X11/xkb/rules/base.lst , start with grp: and end with toggle . To get the full list of available options, run the following command:

Note that the grp:alts_toggle option is unreliable and unlikely to be fixed; prefer other combinations!

Terminating Xorg with Ctrl+Alt+Backspace

By default, the key combination Ctrl+Alt+Backspace is disabled. You can enable it by passing terminate:ctrl_alt_bksp to XkbOptions . This can also be done by binding a key to Terminate_Server in xmodmap (which undoes any existing XkbOptions setting). In order for either method to work, one also needs to have DontZap set to «off» in ServerFlags ; however, from at least version R6.8.0 (year 2004) [1] this is the default.

Swapping Caps Lock with Left Control

To swap Caps Lock with Left Control key, add ctrl:swapcaps to XkbOptions . Run the following command to see similar options along with their descriptions:

Enabling mouse keys

Mouse keys, not to be confused with the keys of the mouse, is disabled by default and has to be manually enabled by passing keypad:pointerkeys to XkbOptions . This will make the Shift+NumLock shortcut toggle mouse keys.

See also X keyboard extension#Mouse control for advanced configuration.

Configuring compose key

Though typically not on traditional keyboards, a Compose key can be configured to an existent key.

Читайте также:  All windows mango phones

The Compose key begins a keypress sequence that involves (usually two) additional keypresses. Usage is typically either for entering characters in a language that the keyboard was not designed for, or for other less-used characters that are not covered with the AltGr modifier. For example, pressing Compose ‘ e produces é , or Compose — — — will produce an «em dash»: — .

Though a few more eccentric keyboards feature a Compose key, its availability is usually through substituting an already existing key to it. For example, to make the Menu key a Compose key use the Desktop environment configuration, or pass compose:menu to XkbOptions (or setxkbmap: setxkbmap -option compose:menu ). Allowed key substitutions are defined in /usr/share/X11/xkb/rules/base.lst :

If the desired mapping is not found in that file, an alternative is to use xmodmap to map the desired key to the Multi_key keysym, which acts as a compose key by default (note that xmodmap settings are reset by setxkbmap).

Key combinations

The default combinations for the compose keys depend on the locale configured for the session and are stored in /usr/share/X11/locale/used_locale/Compose , where used_locale is for example en_US.UTF-8 .

You can define your own compose key combinations by copying the default file to

/.XCompose and editing it. Alternatively, create an empty

/.XCompose and include the default one using include «%L» , for example:

The compose key (denoted as in the

/.XCompose file) works with any of the thousands of valid Unicode characters, including those outside the Basic Multilingual Plane. Take a look at the Compose(5) man page, it explains the format of the XCompose files.

However, GTK does not use XIM by default and therefore does not follow

/.XCompose keys. This can be fixed by forcing GTK to use XIM by adding export GTK_IM_MODULE=xim and/or export XMODIFIERS=»@im=none» to

Currency sign on other key

Most European keyboards have a Euro sign (€) printed on on the 5 key. For example, to access it with Alt+5 , use the lv3:lalt_switch and eurosign:5 options.

The Rupee sign (₹) can be used the same way with rupeesign:4 .

Switching state immediately when Caps Lock is pressed

Those who prefer typing capital letters with the Caps Lock key may experience a short delay when Caps Lock state is switched, resulting in two or more capital letters (e.g. THe, ARch LInux). This occurs because Caps Lock is enabled immediately once the Caps Lock key is pressed, but is only disabled upon release of the second key-press. This behaviour stems from typewriters where a Caps Lock function was achieved by physically locking the shifted typebars in place, and the release of a shift key-press was the action that caused the release of the lock.

Some more popular operating systems have removed this behaviour, either voluntarily (as it can be confusing to some) or by mistake, however this is a question of preference. Bug reports have been filed on the Xserver bug tracker, as there is currently no easy way to switch to the behaviour reflected by those other operating systems. For anyone who would like to follow up the issue, bug reports and latest working progress can be found at [2] and [3].

Workaround

First, export your keyboard configurations to a file:

In the file xkbmap, locate the Caps Lock section which begins with key :

and replace whole section with the following code:

Save and reload keyboard configurations:

Consider making it a service launching after X starts, since reloaded configurations do not survive a system reboot.

One-click key functions

To assign an additional one-click function to a modifier key, you can use xcape . For example it is possible to have CapsLock work as Escape when pressed alone, and as Control when used with another key. First set the Control swapping using setxkbmap as mentioned earlier, and xcape to set the Escape association:

You can set multiple associations separated with a semicolon, e.g.: Caps_Lock=Escape;Shift_L=Escape .

If you hold a key for longer than the timeout value (default 500 ms), xcape will not generate a key event.

Adjusting typematic delay and rate

The typematic delay indicates the amount of time (typically in milliseconds) 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. Note that these settings are configured separately for Xorg and for the virtual console.

Using xset

The tool xset can be used to set the typematic delay and rate for an active X server, certain actions during runtime though may cause the X server to reset these changes and revert instead to its seat defaults.

For example to set a typematic delay to 200ms and a typematic rate to 30Hz, use the following command (use xinitrc to make it permanent):

Issuing the command without specifying the delay and rate will reset the typematic values to their respective defaults; a delay of 660ms and a rate of 25Hz:

Using XServer startup options

A more resistant way to set the typematic delay and rate is to make them the seat defaults by passing the desired settings to the X server on its startup using the following options:

  • -ardelay milliseconds — sets the autorepeat delay (length of time in milliseconds that a key must be depressed before autorepeat starts).
  • -arinterval milliseconds — sets the autorepeat interval (length of time in milliseconds that should elapse between autorepeat-generated keystrokes).

See Xserver(1) for a full list of X server options and refer to your display manager for information about how to pass these options.

Источник

Оцените статью