
#Hammerspoon download mac install#
Here is an example a file which imports the Hyper mode and binds a few keys: - Load and install the Hyper key extension. Now we have the basics and we can use this to bind arbitrary Lua-functions to keys combined with our Hyper-key. It binds both a key press and a key release function, to turn the Hyper-mode on and off.

The install function will bind to all of the events of the key passed in through the parameter hotkey. Let’s see what this would look like in the Lua script (put it in ~/.hammerspoon/a (or if you’re impatient, download it here): local This =, hotKey, enterHyperMode, exitHyperMode) end return This How Hammerspoon’s modal works to create a new keyboard modifier state To turn it on and off, we use the events from the f18 key we remapped in Karabiner. It allows us to create a keyboard mode, which we can programmatically turn on and off. The feature we will use for this is called hs.hotkey.modal. Now that right_option is causing keypress/-release events for f18, we can use Hammerspoon to tap into the MacOS keyboard event system and create our own layer of keys. This will allow you to follow the post below exactly and keep your a clean so you can more easily add other features to it later.
#Hammerspoon download mac code#
If you are not familiar with Hammerspoon and/or Lua, I suggest you put the coming code snippets in a file ~/.hammerspoon/a and import it from a file ~/.hammerspoon/a. For more information on its capabilities and ways to install it, please see my previous post about it. Hammerspoon is an interface between a Lua scripting engine and various MacOS APIs. F18 is just the value that was used in an example I once found, which led to this setup.
#Hammerspoon download mac free#
That means anything above F12 is free to use for these things. Why F18 you ask? Well, it’s a key that’s (probably) not on your keyboard and yet MacOS supports function keys up to 20. Of course this is where you can choose which key should be your Hyper key.

To start setting up the Hyper key, create a new item on the Simple modifications tab and remap the right_option to f18 for all devices. Then, you can start remapping keys in the Simple modifications tab, view your currently connected devices in the Devices tab (and later also disconnected devices, since Karabiner remembers them). Once installed, start it and make sure it starts when you login. You can begin by downloading Karabiner-Elements from its website. Karabiner can do a whole lot more, but right now this is all I use it for (and for remapping Windows-keyboards to proper Mac-layout 😇). That help comes from Karabiner, a tool for reassigning keys on your keyboards. Hammerspoon does require a little help to get this done. While it is most natural to enable and disable this mode in tandem with a key-press and -release, you can actually enable it whenever you like. Hammerspoon enables this behaviour by defining a completely new “modal” key, over which you have complete control.

It acts as a new modifier to all the other keys on your keyboard. The Hyper key is a custom sibling of Shift, Option, Control and Command. Best of all: you get to choose which button you sacrifice. Well, what if I told you there’s a way to create a completely new layer on your keyboard? What if I told you this way no application will ever be able to steal your shortcuts? All you need to sacrifice is one tiny button on your keyboard. Two (or more) applications wanting to use the same shortcut and no way to change them. If you like shortcuts and try to use them in every application, you will run into it eventually: Shortcut Hell. Solve Shortcut Hell in MacOS - Building a Hyper Key
