Remap a broken key

Remapping of space keyI recently had to fix a broken space key on the keyboard of a netbook. My first thought was to remove and check the broken key to check if it could be fixed. I found a temporary solution by increasing the pressure on it, but it just helped for a short time. Then I realized that it was of course possible to simply remap the key to another key which would probably never be used.
The system was fortunately Ubuntu, so with the power of the terminal at my hands it was not very difficult.
To remap it temporarily, you first need to run the following command.

Remember or write down the key code being showed when pressing the key you want to remap to. In my case I wanted to use the key just next to the space key – keycode 102.
After finding the information with xev, you have to use the command xmodmap.

That’s it! Now you have two space keys; the broken one and the new one.

If you restart at this point the changes you made will be lost. You therefore need to make a shell script and make it run at start-up.

Save this to whatever folder and file name you prefer (for example ~/scripts/remap_space.sh). You thereafter have to make it executable.

There’s many places where you can put your start-up scripts, it all depends on your distribution. One place that usually works is /etc/rc.local. Edit the file by using the following command (this depends on your distro and which applications you have installed).

rc.local script

or if you prefer the simpler text editor nano

Add the following to the end of rc.local.

for example

Now you can restart your computer without the remapping disappearing.

  • Atheochar

    can someone tell me where i must put the exec /PATH TO YOUR SCRIPT/script.sh,
    something like that: rc.local: exec /home/user/remap_space.sh
    and thats all?
    thanks in advance…