How to remap broken keys with Xmodmap
We can use Xmodmap
instead of installing yet-another-tool for remapping keys, ie your r
or v
died and you want to use a spare CapsLock + <key>
to trigger that dead key.
Create a file ~/.Xmodmap
touch ~/.Xmodmap && vim &_
Here's my example how to remap keys:
! keycode 66 is caps lock
keycode 66 = Mode_switch
keysym h = h H Left
keysym l = l L Right
keysym k = k K Up
keysym j = j J Down
keysym q = q Q z
keysym w = w W x
keysym e = e E c
keysym r = r R v
keysym i = i I Insert
keysym g = g G Home
keysym b = b B End
! ^: asciicircum, |: bar
keysym f = f F asciicircum bar
! u: Page Up, d: Page Down
keysym u = u U Prior
keysym d = d D Next
keysym BackSpace = BackSpace BackSpace Delete
if you want to find a specific key like caps lock:
# press any key to get the key code
# after running this command:
xev
Then add these to ~/.zshrc
or ~/.bashrc
file:
#you may logout to see changes
xmodmap ~/.Xmodmap