How to repair broken keys in a keyboard cost-free on Linux

Problem

If you have some keys not working on your keyboard, normally you would buy a new one, which may may cost between 50 or 100 dollars, but there's a very simple solution that you can do to use your keyboard again without replacing it and it's an entirely cost-free solution!

In my example, I have a laptop with all the QWERTYUIOP row that wasn't working, requiring Tun (the owner of the laptop) to use a virtual keyboard every time those keys were needed. A really painful and slow solution!

Solution

The solution was simple: Using the central row as the replacement of the first (not-working) one by pressing a modifier key. This key was chosen to be ; which is easily accessible from all positions.

In short, if she presses A, the key A is printed, but if she presses ";" and then "A", the key "Q" is printed, perfect!

So first, edit your ~/.Xmodmap

scite ~/.Xmodmap

And then paste a similar code as this:

Note: You need to use your own keys configuration, so modify this to your needs!

! redefine the central line for use as the the broken ones using the new modifier key
keysym a = a A q Q
keysym s = s S w W
keysym d = d D e E
keysym f = f F r R
keysym g = g G t T
keysym h = h H y Y
keysym j = j J u U
keysym k = k K i I
keysym l = l L o O
! since P doesn't works, let's use the zero for it, which is the upper-upper alternative
keysym 0 = 0 parenright p P
! since we already used the semicolon key as a modifier key, we need a new semicolon key, so we will use the minus key for it
keysym minus = minus underscore semicolon colon
! This is the most important key, the modifier that makes working all the other ones (originally semicolon, changed to be a modifier, you can change it if you want)
keysym semicolon = Mode_switch Mode_switch Mode_switch Mode_switch Mode_switch Mode_switch

Procedure tips:

  • Run the "xev" tool from a terminal to know the default key names when you press them
  • Run this command to test your settings:

setxkbmap us ; xmodmap ~/.Xmodmap

Autostart

E16 probably won't load this file by itself, in which case you can simply add it to the autostart applications with this simple command:

echo " xmodmap ~/.Xmodmap" >> ~/.e16/startup-applications.list

Done! :happy_dance:

2 Likes

I could've use this Howto a while back when a certain diagonal area on my X1 Carbon 3rd gen stopped working.
It's been solved by replacing the keyboard ... but that wasn't easy. It required 36 tiny screws to be removed after the MB and all other peripherals were removed. :shocked:
Usually replacing a keyboard on a thinkpad laptop is easy --- this certainly wasn't. :frowning_face:

Using a bluetooth external keyboard was a solution too albeit a bit daft next_to or on_top_of a laptop. :madness: