How to Remap Keyboard Keys in Linux

Seif Elredeini
1 min readJan 29, 2024

--

Remap keyboard keys on (Ubuntu, Zorin OS, etc…)

Remap not working keyboard keys to other keys

This is a quick tutorial on how to assign different keys to do different things on the keyboard if you have a couple of keyboard keys that are not working. In this example, I replaced the Spacebar with the right CTRL.

we will use a utility called Xcape, it's installed by default on the Linux system.

Steps:

1. Install xcape

sudo apt-get install xcape

2. Create a Script

Create a script, for example, xcape_space.sh, to configure xcape:

nano ~/xcape_space.sh

Add the following content:

#!/bin/bash
xcape -e 'Control_R=space'

Save the file and exit.

Make the script executable:

chmod +x ~/xcape_space.sh

3. Configure Startup

Open ~/.xprofile for editing:

nano ~/.xprofile

Add the following line to the file:

~/xcape_space.sh &

Save the file and exit the text editor.

4. Restart Your System

To apply the changes, restart your system or log out and log back in.

Now, tapping the right Control key should generate a space character.

Conclusion

Customizing keyboard behaviour on Linux provides flexibility to tailor your system to your preferences. With the xcape utility, you can easily remap keys for a more personalized experience.

EXTRA COMMAND:("For READING THE KEYCODE")
xev -event keyboard

--

--