Double-tap Modifier Hotkeys in Any Application
PHPStorm has this great feature where you can double-tap the shift key to open the “Search Everywhere” utility (or at least that’s how I’ve configured my PHPStorm). It’s wonderful and I use it all day. I wanted the same behavior in some of my other applications but quickly realized it’s not achievable out-of-the-box, even with Keyboard Maestro. I tried to use the double-tap usb device key as a trigger but it didn’t work. I ended up solving the problem using Karabiner Elements.
The idea is simple: Use Karabiner Elements to turn a double-tapped left shift into a hotkey I’d not realistically have set up in any application, then use that hotkey as the hotkey in Keyboard Maestro. I chose <cmd-shift-opt-ctrl-f>.
First, here is the code, which you can create as a Complex Modification in Karabiner Elements:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
{ "description": "Mac OSX: double-tap left shift key → cmd-shift-opt-ctrl-f", "manipulators": [ { "conditions": [ { "name": "left_shift_pressed", "type": "variable_if", "value": 1 } ], "from": { "key_code": "left_shift", "modifiers": { "optional": ["any"] } }, "to": [ { "key_code": "f", "modifiers": ["command", "shift", "option", "control"] } ], "type": "basic" }, { "from": { "key_code": "left_shift", "modifiers": { "optional": ["any"] } }, "to": [ { "set_variable": { "name": "left_shift_pressed", "value": 1 } }, { "key_code": "left_shift" } ], "to_delayed_action": { "to_if_canceled": [ { "set_variable": { "name": "left_shift_pressed", "value": 0 } } ], "to_if_invoked": [ { "set_variable": { "name": "left_shift_pressed", "value": 0 } } ] }, "type": "basic" } ] } |
Once you have that in place, double-tapping left-shift should be seen as <cmd-shift-opt-ctrl-f> (it’s as if you hit that hotkey directly).
You can then use that hotkey in Keyboard Maestro, or if your application allows keyboard hotkey customization, just update your applications’ keyboard shortcuts to utilize that <cmd-shift-opt-ctrl-f> hotkey.
If you go with Keyboard Maestro, you can either do it per-application (if you use application-specific groups), or you can create a global macro with a Switch/Case action to handle each application differently. Here are those examples (the “Comment” action is just an FYI for future self).