Sublime Forum

Map double-tap shift key to command

#1

I come from PyCharm where I use the double-tap shift key for the “Go to anything” command.
I tried to map that in ST3 Mac OS X, but it doesn’t work. Here is my try:

{ "keys": ["shift", "shift"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },

What am I doing wrong? Or is it just not possible?

0 Likes

#2

For things like this, you need an external keyboard mapping tool. On Windows, I use autohotkey. There’s probably something similar for OS X.

1 Like

#3

TL;DR: ST doesn’t support using only modifier keys in a keybinding. You could potentially write a Python plugin to do it though:

2 Likes

#4

As @kingkeith observed, ST doesn’t directly support binding modifier keys, but it’s easily possible to run the command you want running this from the shell:

/usr/local/bin/subl --command "show_overlay {\"overlay\": \"goto\", \"show_files\": true}"

By far the easiest way to do this is to use Keyboard Maestro. Here is a Keyboard Maestro macro that will run that command when shift is pressed twice. You can add it to a Macro Group that is only active when ST is being run. The downside to all of this is that Keyboard Maestro is currently $36, although with a 30-day preview.

A free option (if you’re using a version of OS X prior to Sierra) is to use Karabiner to execute the same shell command with a filter to specify that it only works when ST is active. Unfortunately, I’m using Sierra, so I can’t post a working example.

2 Likes