
Open up Karabiner Elements and add the following rule to Simple Modifications:Īlternatively, you can add the following to the "simple modifications" section in your ~/.config/karabiner/karabiner/karabiner.json file, which can help if you want to add the configuration to your dotfiles. Remapping CAPS LOCK with Karabiner Elements
KARABINER ELEMENTS CAPS LOCK INSTALL
Prerequisitesįirst download Karabiner Elements and Hammerspoon from their pages or by using Homebrew: brew cask install hammerspoonġ. In our approach we will also be using Karabiner Elements for the initial key remapping, but we will be extending this functionality using Hammerspoon. If you don't, a simpler approach using only Karabiner Elements might be better. This is why I recommend the Hammerspoon approach if you have programming or technical experience. However, Hammerspoon gives you a lot of power in terms of automation and customisation tools. Let me start by saying that there are multiple ways to set up a Hyper key, and our Hammerspoon approach is not the most simple one. In this guide we will be rebinding the CAPS LOCK key, since this is one of the least used and most redundant keys on the keyboard. The best solution to this is using a key that has relatively little use in day to day life, and rebind this as a Hyper key. By setting up such a key, we make sure that we can always count on our global shortcuts to work, no matter what application we're using.īut how do we do this? All keys on the keyboard have their use, and we can't really add any new ones. The Hyper KeyĪ Hyper key is a special key that is reserved only for these global shortcuts, to keep it completely separate from our regular environment and applications. To overcome these issues, we will be setting up a so-called Hyper key, a special key reserved only for global shortcuts. However, the reason that most applications don't do this is because it is highly impractical to press ⌥⌃⌘⇧ at the same time. One way to do this is using all modifier keys for these shortcuts, since most applications don't use all modifier keys at once. In order to make sure that we can always access this functionality we need to bind it to global shortcuts, of which we know that they are not used by other applications. For some tasks this can be acceptable, but there is definitely some functionality that needs to work in all contexts, like resizing windows, opening certain applications, or locking your screen. Every application has their own shortcuts, making it very likely that some of them overlap. This has happened to me on multiple occasions. Wait, why did I move to the next tab in my editor?' The other modification necessary is changing the bundle identifier that Karabiner uses to identify which window we are talking about.'I will just move my active window to the right, using ⌥⌘→. Firstly, because I’m using a terminal called kitty, you’ll see that in the description and title sections.

There are only a couple things you might need to change for your use case. Now copy and paste the following JSON into the new file: You can name it whatever you like - but add a. Now you can open your text editor of choice and create a new file inside ~/.config/karabiner/assets/complex_modifications. Once you’ve installed Karabiner, open it and run it. Change Caps Lock to Control only in your terminal application.

Change Caps Lock to Command in all applications except your terminal application.

Through Karabiner’s “complex modifications” section, we can write a little configuration file which achieves the following goals: Karabiner (or more specifically, Karabiner-Elements, is a macOS application which emulates a keyboard device, and allows deep customization. I talked about this in a previous blog post, where I used iTerm and some shortcut trickery to send ctrl-codes to my terminal whenever it received command key shortcuts.
KARABINER ELEMENTS CAPS LOCK MAC
My HHKB has a Control key where you’d expect to find a Caps Lock key (which is great, by the way), so using a standard Mac keyboard on my laptop is jarring. One of the larger reasons I find myself switching between OSes, and away from macOS in particular, is its inability to play nice with non-standard keyboard layouts.
