DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 967,911 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Keyboard optimizations in GNU/Linux
Amin
Amin

Posted on

Keyboard optimizations in GNU/Linux

Today I'm going to show you a simple command to enhance the repeating keys on a GNU/Linux operating system. After reading this article, you'll be able to:

  • Change the delay at which a key starts to enter in repeat mode
  • Change the rate between each repeat of the key
  • Save these settings so that you can reuse them for other machines as well
$ xset r rate 250 60
Enter fullscreen mode Exit fullscreen mode

Before you try this command, I suggest you start hitting a key until it starts to repeat automatically. Now copy/paste the command I just showed you in the terminal and notice how the repeating is now faster.

The delay is the moment before a key start going into repeat mode. You can adjust the speed at which it occurs by increasing or decreasing the value 250 in the command.

Whereas the rate is the speed at which a key will repeat itself. This is the value 60 I just set in the above command. Start by typing something like a script or write a program right now to get used to it. If you find it too slow or too fast, you can still change the rate and run this command again.

One last thing to note: this setting will last as long as the session lasts. So if you really want to go back to your stock settings, you just have to logout/login (or reboot your computer). And since it won't stick between logout/login, you'll have to write them in your *rc file, for instance for Bash:

$ vim ~/.bashrc
Enter fullscreen mode Exit fullscreen mode
#!/bin/bash

# Your pre-existing configuration here...

# Update the repeat delay and rate of the keyboard
$KEYBOARD_REPEAT_DELAY=250
$KEYBOARD_REPEAT_RATE=60
xset r rate $KEYBOARD_REPEAT_DELAY $KEYBOARD_REPEAT_RATE
Enter fullscreen mode Exit fullscreen mode

Note that xset should be already installed on most of the GNU/Linux distributions out there and chances are that there is a package available for your distribution if it does not come pre-installed.

Also, this tip will only work with graphical environments. You can look at kbdrate if you want to update your keyboard rates & delays under a TTY session.

Top comments (2)

Collapse
 
drazik profile image
drazik

Thanks for sharing. When I plug an external keyboard on my laptop via USB, the settings are resetted. I have to open a new terminal instance to load the bashrc file and get my settings back. Do you know if it's possible to avoid the settings being resetted when a new keyboard is plugged in?

Collapse
 
aminnairi profile image
Amin Author

Hi @drazik

You can use a udev-rule in order to detect a device. All devices are mapped to a unique identifier that you can use to filter your rule in order to run some script (that will contain you wanted configuration for the keyboard rating).

Hope this helps!

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.