Press and hold modifiers for one action?

I would like to use a shortcut (eg. ctr + a) to press and hold ctr + cmd + shift. Then I press an F-Key, action is triggered and the modifiers are released again.

I don't know how to do this, can someone help? Thanks a lot.

I don't think Keyboard Maestro can hold modifier keys down with its native Actions. However, a search found a possible solution to that:

But if you could explain why you need to do this there might (probably will be) a simpler solution.

1 Like

Hi Zabobon. This is a need for luxury :slight_smile:

For my Macbook air I built a poor man's stream deck with a touch bar simulation app. The point of it all may be of little interest to others.

Imagine you are in your browser. At the bottom of your Macbook screen you see a row of icons arranged exactly over the F-key. For example like this:

Now, if you move your finger to the KM icon, you move it to the physical F6 key. This opens the KM url. (This is set up in the background). Each F-Key does what the icon suggests. (A bit like Stream Deck)

The first row of icons is automatically visible. Additional rows must be displayed with modifiers. As long as you keep the modifier pressed, the additional icons are visible.

Of course, you could just hold down option or command to see the extra row of icons, but those are modifiers that I always use for „normal“ shortcuts. This causes the icon row to flicker every time I trigger any shortcut. This is annoying.

That's why I want to use modifier combinations that I never use otherwise. For example ctr + cmd + shift.

So when ctr + cmd + shift is pressed an hold another icon row is visible, other url will be opened in combination with the F-Keys under the icon. In fact, it simply triggers the shortcout ctr + cmd + shift + Fx, what needs to be set up in the background.

But of course I don't want to trigger this complicated shortcut. I want to replace it, for example with ctr + a (shows the icon row) and then Fx (opens the url).

I have no idea if this is understandable for anyone :slight_smile:

So, when you release ctr + cmd + shift the extra icon row disappears?

Exactly. And visible again is that icon row which is always visible.

Assuming your other "normal shortcuts" are used to trigger KM macros (and not system shortcuts or shortcuts for other apps), there's another avenue you could explore. You could set ⌃A to disable any other macros that use the Fn keys until a selection is made in your Poor Man's Stream Deck (or you click your mouse / hit escape). Honestly though, I think that your life would be a lot easier if you just reserved the Fn keys for this purpose only, so you could use a single modifier to show the second row of icons.

1 Like

Thank you noisneil

„until a selection is made in your Poor Man's Stream Deck“

Do I hear sarcasm here because you have a real Stream Deck :joy: :smiley:

Your suggestion could actually be a solution. I will think about it. At the moment fn is used to hide my "Poor Man's Stream Deck" totally in case I need the screen space.

I will certainly also take into account the hint from Zabobon and try that macro.

If anything else comes to your mind, I'm very interested to hear it.

You came up with that name for it, and I couldn't think of a better way to describe it. No sarcasm, I promise!

Just to avoid misunderstanding, I didn't mention the Fn key (bottom left); I referred to the function keys (top row).

Try this and let me know if it works. I can't test of course, as I don't have your virtual touchbar setup. Apologies for the macro name and icon; couldn't help myself. :wink:

Poor Man's Stream Deck - Alternate Row.kmmacros (49 KB)

Macro screenshot

Thanks noisneil!

Your macro almost works. The modifiers are pressed and held. That is proven by the fact that the second row of icons is shown. So far, so good. Now you would just have to press an F key to have the full key combination. This is what you would expect. But unfortunately it is not the case. The F Key is triggered as a single action. That means: Although the modifiers are already down, I have to press the whole key combination to get the desired result. Really strange...

The second Apple Script works as expected. As soon as I press an F Key, the modifiers are released and the first row of icons is visible again.

Of course I'll be grateful if you find a solution, but don't invest too much time. Although… If we get it right, we'll conquer the market. We already have the brand: The Poor Man's Stream Deck, a revolutionary invention of Frankb and noisneil :rofl: :joy:

That is strange indeed. I just tested with holding ⇧⌘ and pressing the letter "s" and it opened the Save As dialogue, so it works for normal keys. I'm convinced it's because you're holding the Fn key (which is a hardware toggle; not a modifier). So, we'll have to go the long way round.

This is kind of an experiment to see if triggering the full ⌃⇧⌘Fn shortcut separately makes a difference compared to hitting and Fn key while the modifiers are set to "down" using AppleScript.


Poor Man's Stream Deck - Alternate Row.kmmacros (57 KB)

Macro screenshot

Poor Man's Stream Deck - Watch for Keypress.kmmacros (48 KB)

Macro screenshot


The first macro does this:

  • sets the modifiers to "down" in order to show the second row
  • enables the second macro and waits while it listens for Fn keypresses
  • sets the modifiers to "up" which temporarily hides the second row
  • uses the keypress detected in the second macro to trigger a ⌃⇧⌘ Fn keypress, which should hopefully select your desired button in the second row :crossed_fingers:t3:
  • disables the second macro

I have a couple of supplemental thoughts:

  1. If you set your modifier combo to ⌃⌥⌘ instead of ⌃⇧⌘, it's much easier to press, as they're all in a row together and you can just mash three fingers down. That way you wouldn't need to do any of this.

  2. If the above macros don't work, then I have an alternative suggestion. I can't test with your particular shortcuts, but I have established that it does work for other things that don't involve the Fn keys. Therefore, you could try clicking the button icons instead, assuming that it's even possible to click the icons while the modifiers are held down... Try this together with the Watch For Keypresses macro above. You'll have to set the button coordinates in the Click at Button Icon actions.

Poor Man's Stream Deck - Alternate Row (Click Version).kmmacros (67 KB)

Macro screenshot

I would love to tell you that it works. Also to reward your work. But unfortunately it does not. I can't even explain why. My Mac freezes and needs a restart.

„If you set your modifier combo to ⌃⌥⌘ instead of ⌃⇧⌘, it's much easier to press, as they're all in a row together and you can just mash three fingers down.“

That's right. That's why I use this combination a lot for shortcuts. If I would also use it for the Poor Man's Stream deck, the icons would always flicker when I do something completely different. That's exactly what bothers me.

„Therefore, you could try clicking the button icons instead, assuming that it's even possible to click the icons while the modifiers are held down…“

Clicking is already implemented. But I want to touch and not to click. What kind of Stream Deck would it be otherwise? :slight_smile:

Given the circumstances, I'll stick with what I have and thank you very much for your interest in my problem. :pray:

Oh wow. That's unexpected! When you say it "freezes", do you mean the entire system becomes unresponsive?

Do you use that combo for shortcuts involving F1-12?

I'm not suggesting you manually click. I'm suggesting the macro does it for you, so quickly that you won't even see it. Did you look at the Click Version macro?

noisneil, by the way, I was able to solve the problem with another app that allows me to keep any combination of modifiers down until I release it again. Thanks again for your help.

1 Like

Out of interest, was the app?

Not sure if I'm allowed to say that here :slight_smile:
KM's biggest competitor and also the app that works best with KM: BTT.

1 Like

Loads of people use BTT with KM, so you're not being naughty :blush: