Keyboard rate and delay

Here's how to change the rate and delay of your linux system, in direct console or in X, thanks to the command line.

TL;DR

You are using X

  • Set:

    • Command:

      xset r rate DELAY [RATE]
      

      DELAY is in milliseconds, and RATE is in character per seconds.

      • This has no effect on direct console.
    • Example:

      xset r rate 190 38
      
    • Reset defaults:

      xset r rate
      

      Default values are a delay of 660ms and a rate of 25 characters per sec.

  • Query:

    xset q
    

You are in console

  • Set:

    • Command:

      kbdrate [-d DELAY] [-r RATE]
      

      DELAY is in milliseconds, and RATE is in character per seconds.

      • You need permission on /dev/port.
      • This has no effect on X sessions.
      • It affects all direct consoles (the one you can get thanks to Ctrl-Alt-F1).
      • It might not work as expected on exotic keyboards.
    • Example:

      kbdrate -d 190 -r 38
      
    • Reset defaults:

      kbdrate
      

      Default values are a delay of 250ms and a rate of 11 characters per sec.

More info

Definitions

keyboard press delay
is the time waited while the key is pressed before the keyboard issues more character than one.
keyboard character rate
is the number of character per second once while you keep the key pressed down and only after you've waited the previous delay.

Context

There are roughly two different UI context where you might want to fiddle with the keyboard's rate and delay: you are in a X session, or in direct console.

If you are in a graphical X session, then it is X. X is listening for scancodes that are roughly events about keys going up, or keys going downs. So X can implement its own algorithm to produce characters and can choose its own delay and rate.

If you are in a direct console (Ctrl-Alt-F1 for instance), then it is your BIOS that is handling the rate through interrupt 16h. kbdrate uses an ioctl call to change the settings and this might not work if you have some exotic keyboard. You most note that this will affect all the consoles of the computer, but this won't have any effect on your X sessions.