Aral Balkan

Mastodon icon RSS feed icon

Key Mapper: a visual tool for remapping keys (and more) on Linux

Screenshot of the Key Mapper application running in dark mode. The Device selection box reads Topre Corporation Realforce 87. The interface has buttons for Restore Defaults, Apply, Copy, New, Delete. On the left-hand side form, a selection box labelled Preset has Typography selected. Under that, a rename text box is empty (with an action button next to it). Finally, there’s an Autoload switch that’s on. On the right-hand side, there is a two column table, headings: key, mapping. There are four mappings: (key) ISO Level3 Shift + bracketLeft → (mapping) ISO_Level3_Shift + Shift_R + v, ISO Level3 Shift + bracketRight → (mapping) ISO_Level3_Shift + Shift_R + b, (key) ISO Level Shift + semicolon → (mapping) ISO_Level3_Shift + v, (key) ISO Level Shift + apostrophe → (mapping) ISO_Level3_Shift + b

Mapping keys has never been easier in 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 xmodmap, 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:

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

  1. Hey, don’t judge me! ↩︎

  2. I just grabbed the .deb file from their releases page. ↩︎

  3. 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. ↩︎

  4. 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. ↩︎

  5. 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. ↩︎