Double Tap Cmd/Opt/Shift/Control as Hotkeys

Could these be possible to add as hot keys for our macros in the future? What I mean specifically, is for example, I can simply use a double-tap on the command key to launch a macro. Currently Keyboard Maestro doesn't seem to allow this. I see that I can set "tap twice" "tap 3 times" and so on, but I can't use a command (or opt/shift/control) by itself only in combination with another key.

It must be possible to enable this, because Alfred allows you to simply double tap on one of these keys in their Workflows.

If I recall correctly, this has been discussed before, but as of right now there are no plans for it. I’m happy to be proven wrong though!

That being said, you could always trigger the KM macro via an Alfred workflow, using the “Or by shell script” KM trigger that appears below the main triggers, and pasting the script into the Alfred workflow. I just set up a simple test case that you can see in the following screen shots and it works well.

Keyboard Maestro macro screenshot (click to expand/collapse)

Alfred workflow overview screenshot (click to expand/collapse)

Alfred workflow action screenshot (click to expand/collapse)

1 Like

Thanks for the response!

Too bad it isn't being considered, but thanks for the workaround! I'll try that workaround out here in a little bit and let you know if I have any questions about it.

For a very long time I've been using the key to trigger macros. Here's an example showing the left and right Option keys double-tapped being used as a trigger:


A couple of things to notice about this:

  1. I use the USB device key trigger.
  2. I also use Karabiner Elements to map the shift-lock key to the hyper key combination: . (I don't know if that's relevant.)
  3. Finally, I use an Apple Magic Keyboard with my iMac.

I don't know if this still works if you don't use Karabiner Elements, but I suspect that it won't work if you don't have an external keyboard. It does also work with the control and shift keys.



After a short test, I can confirm that @tiffle's method works well, even with an internal keyboard. This could be interesting for users who want to keep their fingers on the keyboard and their eyes on the screen.

  • Tab or double tab works with all left/right modifiers, including fn.

  • Modifier combinations are also possible, e.g. left cmd down + tap right cmd. Or any other combination. This works like modifier + letter.

  • It works well even with palettes. Eg tap left/right cmd (or shift), opens a palette. This doesn't interfere with normal shortcuts (cmd + letter), or capitalization with shift.

If I wasn't already doing all this with BTT, I'd certainly be doing it with KM. :smiley:

@peternlewis I don't know if you want this or if this is possible, but shortcuts with fn would be available if fn was added here

Check out the Hotkey / USB Key macros here:

Ah, yes, I forgot to mention that, because I use BTT for these "modifier shortcuts" (because also fn works) and your macro for the "real" shortcuts. But of course, this also works with your Multi-Press macro :smiley:

1 Like

Fn is not a modifier and can't be used with the system hot key API.

I think what @Frankb means is that you can use the state of the Fn key (or any key) as a global condition which, in practical terms, feels a lot like using a modifier.

1 Like

How to understand this technically, I leave to those who know something about it. In practical use, it would be nice if a certain key could be held down (in this case fn) while another one is pressed.

Hello Frank

I am currently working on a new post of a Submacro and a Subroutine checking for things like a held fn key but this will not be ready for you in time.

In the time you have to wait you can of course try something your self borrowing the ASObjC code posted in the OP of my Multi-Press Templates Post.

If I remember it correctly it has a routine for watching the fn key built in so you can use it as it is for your purpose.

If you have any questions about that piece of code just ask me

Greetings from the sunny city Wetzlar in Hessen :wink::sunglasses:


1 Like

Thanks Tobias! As I said, I use BTT for this. The app treats fn like all other modifiers.



I have long been aware that one automation app can not do everything. The combination of KM and BTT is perfect. What one app can't do, the other can. :smiley:

1 Like

Because Fn is not, in Apple's terms, a modifier key, utilities that value compatibility/stability and so only use Apple's published public APIs won't know when it is pressed.

Some utilities go beyond those APIs, working "behind the scenes", and offer more functionality -- but there's always a risk of sudden breakage when Apple quietly change something.

Yes, Apple do also change the public APIs -- but that's usually either accidental and quickly reverted, or publicised enough in advance that developers can make changes in readiness. Although I'm sure @peternlewis has plenty of war stories from the times that process hasn't worked as advertised...

1 Like

Thanks @Nige_S, I realize that. But that shouldn't stop a problem solver like you from thinking about what @noisneil suggested. :smiley:

"you can use the state of any key as a global condition which, in practical terms, feels a lot like using a modifier."

I have tried this as well as I can. Unfortunately, since I can do almost nothing, my solution is pretty much useless. But it works, which at least proves that the basic idea could be implemented.

Suppose "f" is to be used as a "modifier". Eg f + j shall trigger a macro without typing "f" or "j". But of course "f" and "j" typed alone should be these letters.

My ridiculous macro below works. In addition it needs the macro "j" long press, does nothing. Short press = j.

If you or someone would implement the idea correctly, maybe someone can even use this. :joy:

F + J Down = Any Action (nothig ist typed).kmmacros (5.6 KB)

Yes and no.

Say, for example that Keyboard Maestro tried to do this with the Fn key as a modifier.

It can track the state of the Fn key, and know if it is down or up. That's fine.

So you have a hot key trigger active for say Fn-A. But since Fn is not a modifier, that means the hot key trigger would actually be for A, and then when the trigger fired, Keyboard Maestro could check whether the Fn key is down or not. If it is it runs the macro. That's actually probably all doable.

But what if the Fn key is not down. The A key has already been swallowed by the system, and sent to Keyboard Maestro as a hot key. There is no getting out of that without problems. Keyboard Maestro cannot then type an A or add an A to the event queue, because if it did it would end up being out of sequence. For example, you type "A", and "B" in quick succession, so the event queue as "A" and then "B" in it, and then the "A" is processed, swallowed, sent as a hot key, decided that there is no Fn key pressed, added to the event queue, which then has "B" and "A" in it, and assuming the hot key was then disabled for a short (but unknown) amount of time, you would get the out of order sequence "BA".

I understand, and I've found that fast typing can sometimes be an issue with fairly complex macros, but is that really true in practice for something as simple as a single key up/down check? I've tested the same detection idea with keys other than Fn and haven't found it possible to type fast enough for the sequence to be disrupted.

If I hit FnG while capturing a hotkey trigger, KM sees it as just G.

When it comes to triggering the macro, FnG does nothing but G will trigger the macro.

If Fn were ignored as a trigger the way it is ignored when a trigger is captured, then using it as a pseudo-modifier would be feasible.

I'm probably seeing something entirely backwards, but that's how it appears to me.

You got me thinking, so I tried capturing the Fn as a hotkey using the USB Device Key and got this:


Now, when I press the Fn, the macro triggers!

Note: Everything I said in Post 3 above still applies - so YMMV.

I was referring specifically to hotkey triggers, whereas you captured it as a USB device key. That works, just as with any key, and can be used to capture the Fn key state as a variable like this:

Fn - Detect.kmmacros (22 KB)

Macro screenshot

The problem is that, even though Fn isn't accepted as part of a hotkey trigger, holding Fn does affect how KM sees other triggers.

Holding Fn and hitting G will be captured by KM's trigger input field as just G. So we might expect that holding Fn has no bearing on G as a hotkey trigger. However, Fn+G will not trigger the macro but G alone will.

This is unfortunate as it precludes the use of the above detection macro.

What seems to work somehow is this.

fn down/up shows/hides a palette, but the single key trigger of a macro on the palette is a string.

eg fn + j = left arrow