~habibalamin/Commandeer

Remap command key to escape when pressed alone
Merge branch 'fix-alfred-swallowing-space-and-triggering-escape'
Fix Alfred swallowing space and triggering escape

clone

read-only
https://git.sr.ht/~habibalamin/Commandeer
read/write
git@git.sr.ht:~habibalamin/Commandeer

You can also use your local clone with git send-email.

#Commandeer

This is a small background app for macOS that remaps command to escape when pressed alone, i.e. neither used as a modifier nor held for longer than a brief sub-second window of time. It sits in the menu bar, and you can quit it from the menu bar.

#Why?

I had started a command-as-escape-when-pressed-alone remapping years ago when Apple came out with their stupid touch bar laptops without a physical escape key which an old employer provided for me. It ended up working so well for me that I quickly started used it on my personal machine as well, which doesn't have a touch bar.

This can be done with Karabiner Elements, but while Elements is versatile, it's also quite brittle.

I've been living without a caps lock key for a while after it broke it, and I even had to disable caps lock using it, otherwise it bricks the keyboard until reboot after hitting caps lock (enough times?).

I'm not so fussed about caps lock in particular, but when I started working with a new client who provided their own locked down machine, Elements stopped working (if it ever did on that machine, I think an update actually broke it).

I knew I had to figure out my own solution outside of Elements like I did with Metalt. Commandeer, which hooks into Apple's Quartz Events framework instead of reading directly using a kernel extension, seems to work fine on my locked down machine.

#Usage

To use this, you'll need to give it access in System Preferences -> Security & Privacy -> Privacy -> Accessibility.

When you first launch the app, it'll quit immediately and macOS will pop up a dialog telling you. Follow the instructions to give it accessibility access.

Then, relaunch the app. You should see a green four-leafed clover emoji in the menu bar. That's the app.

You can keep using command as you normally would as a modifier. You can also use it as a shortcut for escape. If you hit it as a shortcut for escape, but change your mind halfway through, simply hold it for longer than 200 milliseconds; if you let go after holding instead of pressing, Commandeer doesn't simulate the escape keypress.