Key Mapper: a visual tool for remapping keys (and more) on Linux
I’m a bit particular when it comes to typing.
Specifically, I like to use good typographical habits whenever possible.
And, I use an external keyboard with a physical ANSI US Keyboard layout set to UK Macintosh layout on my Linux laptop1. So, I need to reclaim my backtick/tilde key.
Previously, I used a combination of
xev, and a .desktop in autostart to handle the backtick/tilde issue – which was about as fun as it sounds to figure out and implement – and the standard Alt Graph modifiers for things like typographical quotes. And while the AltGr modifiers are great and all, they weren’t entirely ergonomic.
When I was on a Mac, I used an awesome tool called Karabiner-Elements to handle all this with a minimum of fuss.
Surely it shouldn’t be this hard to remap your keys in Linux in 2021! Well, thanks to an app I just discovered called (wait for it) Key Mapper, it’s not.
Mapping keys for fun and pedantry
Using Key Mapper is fairly straightforward.
Once you’ve installed2 and launched it, you’re greeted with a simple interface where you can select the device3 you want to create mappings for.
From there, you can create a new set of mappings, give them a name (confusingly in a separate text box called rename) and choose whether they should auto load.4
Finally, you create the mappings themselves by first pressing the key or key combination you want to map and then entering the codes of the key(s) you want them to map to.
Note that you are mapping keys to keys, not keys to characters. The distinction is important. So, for example, to map you’re mapping AltGr + [ to AltGr + Shift + v, not AltGr + [ to
Or, more precisely, using the key names used by Key Mapper, you’re mapping
ISO Level3 Shift + bracketleft to
ISO_Level_3_Shift + Shift_R + v.
Key Mapper is great but it’s not perfect. Here are a few niggles I’ve noticed:
There is a noticable delay of about a second when a mapping fires. This could get annoying fast (and wasn’t an issue with the manual way I was doing mappings earlier).
The mappings didn’t survive suspend. It remains to be seen if that was a one-off or if it keeps happening.
There doesn’t seem to be a way to use a preset from one device on another. Case in point: I wanted to use the same mappings on my external keyboard and on the laptop keyboard so I had to create them twice. Not a huge problem for a handful of mappings but it could be more of a headache for larger lists.
A great start
Having a graphical key mapper in Linux is great. Here’s hoping that some of the niggles are not facts of life and can be improved upon with time.
Worst case scenario, I’ll have to hunt down how I was doing things in the past and reimplement that on my new elementary OS 6 installation.5
Hey, don’t judge me! ↩︎
I just grabbed the
.debfile from their releases page. ↩︎
You’re not limited to keyboards; you can remap keys on mice and gamepads. Key Mapper also states that it works on X11 and Wayland, although I’ve only tested it under X11. And, though I haven’t used them yet, you can also use macros. ↩︎
In my limited testing so far, auto-loading seems to survive sleep for me but it did fail once after a suspend. Getting mappings to stick was also an issue with my homebrew system previously and I don’t remember how I finally managed to make it work reliably at both sign in and after sleep/suspend. I may have to hunt down my backup configuration files or re-read my blog posts that I linked above if this becomes a headache. ↩︎
I plan on writing a comprehensive post on elementary OS once I’ve got my laptop back to running the way I want it to under version 6/Odin. ↩︎