How to remap keyboard buttons in Linux
We have a laptop with a broken arrow key. It's quite annoying! I wondered how easy it would be to remap a different key to be the right arrow key? Turns out it was dead easy on Linux.
This can be achieved using an application called Keyd. This was painless to install from source on Pop_OS.
It works system wide, and is not limited to your user session. It can also seemingly remap the annoying Copilot key if you happen to have a recent laptop.
git clone https://github.com/rvaiya/keyd cd keyd make && sudo make install sudo systemctl enable --now keyd
Once installed, you need to edit the config file at /etc/keyd/default.conf. Mine now looks like this as I remapped the Right Ctrl to be the right arrow key.
The ids section lets you filter events from specific keyboards or mice. I don't need to do this, so I left it as * which means 'everything'.
[ids] * [main] rightcontrol = right
Once this has done, reload keyd by running sudo keyd reload and you should be set. Per the documentation, if you need to remap different keys you can run sudo keyd monitor
Reading keyd Monitor Output
... keyd virtual keyboard 0fac:0ade:bea394c0 d down keyd virtual keyboard 0fac:0ade:bea394c0 d up keyd virtual keyboard 0fac:0ade:bea394c0 leftshift down keyd virtual keyboard 0fac:0ade:bea394c0 d down keyd virtual keyboard 0fac:0ade:bea394c0 d up keyd virtual keyboard 0fac:0ade:bea394c0 leftshift up Basilisk X HyperSpeed Mouse 1532:0082:86d19e94 leftmouse down Basilisk X HyperSpeed Mouse 1532:0082:86d19e94 leftmouse up ...
When you run sudo keyd monitor, it shows you all key press events. Using this, I was able to determine I needed to remap 'right'
This is post 44 of #100DaysToOffload.
To respond on your own website, write a post which contains a link to this post - then enter the URl of your page here. Learn more about WebMentions.
Discussion in the ATmosphere