DEV Community

Michael Kohl
Michael Kohl

Posted on • Updated on

Custom keyboard mappings

As you may have gathered from some of my previous posts, I'm someone who really likes to optimize their tools. This includes remapping some of my keys, e.g. with Karabiner-Elements on macOS.

Here are 3 of my favorite remappings:

  1. Caps Lock as . I don't really have a need for Caps Lock, so I remapped it to a second backspace key.
  2. Shift + as forward delete. Mac keyboards don't have a Del key, and Fn + isn't super fun to type. Given that I already use Caps Lock as backspace, I now have an easy way to forward delete on a Mac keyboard.
  3. Left Shift as ( and Right Shift as ): Shift doesn't do much most of the time and as a software developer I often need parenthesis. So while holding Shift and pressing another letter behaves just like before, pressing Left Shift by itself will insert ( and Right Shift will insert ). Additionally Right Shift + Space will result in ).

Do you use custom keyboard mappings? If yes, what are they?

Discussion (8)

denolfe profile image
Elliot DeNolf • Edited on

I went a little crazy with my keyboard mappings using Karabiner and Hammerspoon. I use CapsLock as a Hyper key to create shortcuts.

  • Hyper Key modifier, Esc when pressed alone
    • CapsLock
    • CapsLock+cmd
  • Directional Bindings (CapsLock) w/ Selection (+cmd)
    • hjkl - VIM arrows
    • n - Home
    • p - End
    • m - Left one word
    • . - Right one word
    • i - Page Up
    • u - Page Down
    • cmd+i - Top of page
    • cmd+u - End of page
  • Remappings
    • CapsLock+delete - Forward delete
    • CapsLock+cmd+delete - Forward delete word
    • CapsLock+a - Spaces left
    • CapsLock+d - Spaces right
    • CapsLock+s - Mission Control
    • CapsLock +cmd+s - Show all app window
  • PC-Style remappings for non-Apple keyboards

I use Hammerspoon to make CapsLock shortcuts for window management and "launch or focus" app shortcuts.

citizen428 profile image
Michael Kohl Author

That's too much even for me 😉 I do like the Vim motion keys though... 🤔

ahferroin7 profile image
Austin S. Hemmelgarn

Not sure if this really counts, but I use a custom keyboard layout on most of my systems that works like a standard US international keyboard layout except that I've inverted the behavior of the dead keys.

On a normal US international keyboard, you have an AltGr key in place of right Alt which will result in different characters when held (for example a becomes á, o becomes ó, y becomes ü, s becomes ß, etc). In addition to this though, you have a couple of what are known as 'dead keys'. When you hit one of these keys, it modifies (depending on the exact layout) either the next or the last letter typed, and you have to hit them twice in a row to type the normal character. In particular, ', ", `, ~ and ^ behave like this.

In my case though, everything I'm likely to need to type is already handled via AltGr, so the dead keys just get in my way 99% of the time, especially considering that quotation marks are very commonly used when programming. So I just modify the layout so that the dead keys only behave like dead keys when I'm holding AltGr, and otherwise type their normal characters instead.

nikoheikkila profile image
Niko Heikkilä

I've been trying to learn Karabiner but couldn't figure out how to map the Shift keys to produce brackets. Care to share how you did it?

So far I have only mapped the WIN-key on my mechanical keyboard to act as Command key when plugged into MacBook.

citizen428 profile image
Michael Kohl Author • Edited on

Go to Search for "Modern Space Cadet". Add to Kariber-Elements and activate the complex modifications "Better Shifting: Parentheses on shift keys" & " Better Shifting: End parenthesis on shift + space". Alternatively you can also just look up the JSON definition there.

citizen428 profile image
Michael Kohl Author

So far I have only mapped the WIN-key on my mechanical keyboard to act as Command key when plugged into MacBook.

My Leopold mechanical keyboard has a physical switch for that at the bottom :-)

victorioberra profile image
Victorio Berra

Anyone else think those bindings would drive them mad? ;)

citizen428 profile image
Michael Kohl Author

Hehe. The human mind is fascinating, after about an afternoon they are muscle memory.