DEV Community

Cover image for how to remap broken keys with Xmodmap
Jaeyson Anthony Y.
Jaeyson Anthony Y.

Posted on • Edited on

2

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 &_
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

if you want to find a specific key like caps lock:

# press any key to get the key code
# after running this command:
xev
Enter fullscreen mode Exit fullscreen mode

xmodmap

Then add these to ~/.zshrc or ~/.bashrc file:

#you may logout to see changes
xmodmap ~/.Xmodmap
Enter fullscreen mode Exit fullscreen mode

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post