Did I Improve ThisBlogAbout

Customizable Key Bindings on macOS

02 August, 2020 - 4 min

Why?

It all started back when I was in college and used to daily drive Windows, with Ubuntu on a virtual machine. I only used Ubuntu from time to time, for specific courses. But when I did I was using vim to do most of the text file editing. The more I used vim, the more I started to enjoy the hjkl movement key bindings (along with a lot of other movement and edit binds).

After a while, whenever I switched to other applications I missed those powerfully simple keybindings. Also, "fishing" for the arrow keys on the keyboard started to bother me. So I decided to look for a way to mimic vim's hjkl key bindings.

I found AutoHotKey. It allowed me to configure the vim keybindings, just like I wanted. To access them I used capslock as a modifier. From that, I decided to start pulling my most used keys to be as close to the home row as possible.

Fast forward a couple of years, when I finally got the courage to go full Linux (thank you André Nogueira for the push!) and started to use i3wm. One of the benefits of i3wm is the way you can navigate through applications and workspaces with your keyboard very easily. I highly recommend it for Linux users. I had i3wm configured so the applications I used the most were each pinned to a specific workspace. Since I had a shortcut for each workspace, I could go to a specific app with a single shortcut. Very productive.

The tilling manager was really great, moving between apps became very easy. But I was missing what AutoHotKey - a Windows only application - did for me before. I needed an app that allowed me to customize my keyboard shortcuts. The alternative ended up being an actual physical keyboard, Vortex POK3R. It allowed me to have programmable layers. With those programmable I could configure the keybindings I needed. You can see here all the keybindings I used. Capslock is working as fn. So, for example capslock + hjkl worked as the arrow keys, capslock + ; worked as backspace, etc.

POK3R layer configuration Fig. 1 - POK3R layer configuration

Currently, since I've joined Revolut, I've been using macOS. On it, I found a different way to replicate the i3wm - applications on specific workspaces - behavior. I have a shortcut for the applications I use the most, which works pretty well since I only use around 9 apps at a time.

Karabiner Elements is the software that allows me to customize my keyboard and create the keybindings I need. At the moment I'm not using my pok3r, I rely solely on Karabiner Elements for all the shortcuts. The next section describes them in detail.

Karabiner configuration

Capslock as a modifier

I use capslock as a modifier key. When used with the keys bellow it acts as a modifier.

Navigation

h - left arrow
j - down arrow
k - up arrow
l - right arrow

u - home
i - page up
o - page down
p - end

Window Control

q - command + q - this comes from the habbit of using it to map alt + F4
w - command + w - this comes from the habbit of using it to map ctrl + w
tab - esc

Sound Control

z - previous track
x - play/pause
c - next track

s - volume down
d - volume up
f - mute

Application

1 - Chat App - Slack (or whichever chat app I'm using at work)
2 - Browser - Chrome
3 - Music - Spotify
4 - Database client - DBeaver
5 - Calendar - macOS default
6 - Text Editor - Sublime
7 - Email client - macOS default
8 - IDE - Pycharm
9 - terminal - iterm

Shifter

; - backspace
' - delete

This is my configuration for karabiner. It was based on vonng's configuration.

You can place it in ~/.config/karabiner/assets/complex_modifications/. Then go to Karabiner Elements - Preferences - Complex modifications - Add rule and load the specific rules you need from the config.



Thanks for reading,

Vicente




Next Steps

My latest tweak keyboard wise has been to learn colemak mod-dh. I was never a fast typist, my qwerty speed is 70wpm. I'm now at around 40 50wpm in colemak-dh, which is enough for me to start using it full time. This is my first week doing so. I hope to explore a little more on the subject on another post.

The next step on my journey to improve my keyboard experience will be when my preonic finally arrives.

Finally I want to give Amethyst a try. One aspect of i3wm that I really miss is the ability to send/attach apps to certain workspaces (called Desktop space on macOS). Thus having the ability to have your workflow focused on workspaces instead of apps. It's usefull if you want to group apps together. Like terminal and notes. Or a music app and a podcast app. Amethyst allows to better manage apps along with workspaces (I think), than simply using karabiner and macOS settings. I know macOS allows to set an app to a workspace, which might solve my problem. I need to play around with the three.