How to break up with your mouse: Part 1, Hyper Key

How to Break Up with Your MouseDeveloper ProductivitymacOS

As a developer, I spend a lot of time working on my computer. There's always more to get done, and so it's important to be as efficient as possible. Anybody who works on a computer all day, developer or not, can probably relate. I find that the slowest tasks I have to do in a day are the ones that I have to use my mouse for. And the less time I have to spend using the mouse, the less I get slowed down.

Over the years, I have found a lot of ways to get away from my mouse, as well as to make my keyboard interactions as fast as interactive as possible. I want to share some of those tips with you in a series of posts that I will call How to Break Up With Your Mouse.

In this installment of How to Break Up With Your Mouse, I'll show explain:

I'm going to share the custom app switcher for macOS I wrote using Hammerspoon. Each app that I use regularly has a hot key, and pressing the hot key opens or switches to that app.

If I press the hot key more than once, it will cycle through the windows of that app. Neat, eh?

I use a keyboard mapping that turns the caps lock key into a "hyper" key, and map my app switching shortcuts to that key. But you can map it to any key combo that is not going to conflict with other keyboard shortcuts. If you want to map your caps lock to a hyper key, read this section. If not, you can skip ahead.

Setting up a hyper key

First, you'll need a free program called Karabiner Elements. Karabiner Elements allows you to create custom key mappings that work across the OS. Once you've downloaded and installed Karabiner Elements.

Once you have Karabiner Elements installed, there are two ways you can set up the hyper key. The first one is simple and will only set up your hyper key, while the second is slightly more complex, but gives your hyper key some additional super powers.

For either option, you're going to want to go into the Complex Modifications tab of the Karabiner Elements preferences dialog.

Option 1: Use the include example configuration

Because mapping a hyper key is such a popular use of Karabiner Elements, it now includes an example hyper key mapping you can use. To use it, under Complex Modifications, click Add rule, then you should see three rules available under 'Examples'. The one you want is labeled 'Change caps_lock to command+control+option+shift'. This will replace your caps lock key with the all-powerful Hyper key.

Option 2: Use my custom Hyper key mappings

I like my caps lock key to do double duty: When I use it in combination with other keys, it sends Command+Option+Ctrl+Shift, but if you press it on its own, it will function as the escape key. I never liked how far out of the way the escape key was, so I use CapsLock as my escape key, before I ever heard of the concept of a Hyper key. Turns out it can do both with no problems!

You'll need a custom configuration file for this one. You can import the one I made directly into Karabiner:

Import Karabineer config

If that won't work, or you'd like to download the file manually, you can grab it from here: hyper-and-arrow-keys.json. Download the file and place it in ~/.config/karabiner/assets/complex_modifications. Create the directory if it doesn't exist already.

Once you've imported the json file or downloaded it manually, Karabiner will be able to use the configurations from the file. On the Complex Modifications tab, click Add Rule at the lower left.

Enable CapsLock to Hyper/Escape. This will make your caps lock key function as the escape key when pressed alone (you'll wonder what you did before this), and it will send Command+Option+Ctrl+Shift when pressed with another key. This combo is nearly impossible to use by itself, so you won't find conflicts with existing keyboard shortcuts, and you can use it to map any custom keyboard shortcuts you like.

If you have imported my custom configuration, there are some other options you can enable. One is to also map the right command key to Hyper/Escape, same as the caps lock key. I find that I never use might right command key, so I tried mapping it to Hyper. I still don't use it.

The other is to the hyper key plus HJKL to the arrow keys. This lets use use Vim-style home row arrow keys anywhere. As a bonus, they can still be combined with modifiers like command or shift, to make editing text in a text editor easier.

What can you do with a hyper key?

Anything you want! Anything that uses a keyboard shortcut can use the hyper key. You've seen one example already, where you can use it to simulate arrow keys with HJKL on the home row.

In How to break up with your mouse: Part 2, I'll show you how to set up an insanely useful app switcher I built that can take advantage of the hyper key to take you straight to any app you want with a single keyboard shortcut.