Short Press Shortcut Do One Action, Long Press Do Something Else

Hey guys,

I made this macro after reading through this thread. I trigger it with Stream Deck buttons and it allows the following for multiple keystrokes:

1 tap = Action A
2 taps = Action B
3 taps or longer press (selected in macro) = Action C

In my case, actions A, B an C output different keystrokes to trigger assignments in nAc, which is the companion app for nOb Control (which I use primarily in Logic Pro).

F Keys Multi-Tap : Long Press.kmmacros (114.8 KB)

It works great and the only things I haven't been able to figure out are:

  • The long press detection seems to have to come first, but it slows down the multi-tap detection. This might be just the way it has to be.
  • If I hold the key beyond the length of time it takes to run through the macro and perform the actions, the trigger keystroke leaks through to Logic Pro and causes a screen-flash error response. Perhaps there's a way to prevent this?
  • F11 and F12 don't seem to work so I've limited it to F1 to F10. There may be some keystroke conflict I'm not aware of, perhaps due to the modifiers being used.
2 Likes

Yes, noticed that. KM doesn’t know if you finished, so it needs to wait for the long press first.
Thanks for sharing!

1 Like

Okay, I like this, but suppose I want the Long Press key to be the letter "j" and it will trigger an action if I leave it press for .5 seconds, otherwise it would just type the letter "j"? I tried it and it didn't work.

Can't be done reliably.

Period.

I don't know about the current version of the engine, but when I first started using KM, I had managed to get it to work. But only in certain circumstances, and I was never sure what those circumstances were. Which is why I said "reliably". :joy:

I'm out of my league here but wanted to let folks know what I was doing....

I actually do this 'sort' of thing.
By using Dan's marvelous HotKey Multi-Press macro, you just can't use the 'single' or one-time press on the key, the single press needs to be cancelled. (for my uses)
You can multi-press the control key (2-5 times set in the macro itself) to trigger different macros OR you can long press the control key and then follow it with any other modifier to trigger different macros. very powerful....
If you long press, the single multi press is cancelled and the long press takes over.

Long press.kmmacros (8.5 KB)

Multi Left ⌃ Control VARIOUS K0020 copy.kmmacros (34 KB)

3 Likes

TBD psuedo long press if J key is held down Macro (v10.0)

TBD psuedo long press if J key is held down.kmmacros (3.5 KB)

1 Like

Edit: see simplified version, a few comments below. It works better while typing quickly.


This works very reliably for me.

Type "J" or Do Something Else.kmmacros (88 KB)

Macro screenshot

Based on the hotkey version of THIS.

1 Like

This is nice. The macro is reliable in itself, but the problem is always the same. It fails when writing fast.

Instead of "jeep" it types "ejep".

1 Like

Yep, confirmed. Hadn't thought of typing fast. Ah well.

The reason for this, seems clear to me. The command "j" (short pressed) would have to be given at "pressed", not at "released". And be deleted again if the key is held longer. This is the "logical" solution, but probably not doable in practice. :man_shrugging: Or what do you think?

The reason, as I see it, is that the processes in the previous macro I posted take too long and interrupt fast typing. That's because I used the full version of the macro, which has all sorts of other options. Here's a version with all that stuff stripped away, and it seems to work well when typing "jeep" as fast as my fingers can manage it.

Type "J" or Do Something Else.kmmacros (47 KB)

Macro screenshot

Let me try it with my fingers :slight_smile:

Sorry, no difference :frowning: I am convinced that it has something to do with "released".

Well there is a difference, but evidently not enough of one to make it bulletproof on your system.

I can't get it to trip up here, so I'm wondering if your mac runs at a different speed; I'm on a 2.4GHz i9.

I have no idea at what speed my M1 Air runs. But I learned many years ago to write fast with 10 fingers :slight_smile:

I think the problem is systemic. Because of the „if“ KM has to distinguish between two actions… Why? Typing J should not be the task of KM.

KM should only have to measure the time and perform one action when that time is exceeded.

J is pressed for less than 1 s. KM only "observes" and does nothing. J is processed by macos.

J is pressed for longer than 1 s, KM intervenes and does something.

This is of course expressed in layman's terms :slight_smile:

I still suspect it's more to do with your mac, as I'm hammering out "jeep" and "jjjjjjjjjj" at break-neck speed without issue... And I'm a drummer. :joy:

As part of detecting the press and release of the "J" key in a standalone macro.

The trouble is, KM "eats" the keypress , so if you want to use J as a hotkey and type J at the same time, you have to simulate pressing "J" as part of the macro.

KM would already have to be aware of the keypress, so J has to be the hotkey. See what I mean?

If you can think of a better solution, I'm all ears.

While a drummer writes "jeep", I bought one long ago. :joy: :rofl: :innocent:

Seriously, your macro is very useful for keys that are not needed in daily writing in rapid succession.

I'd be interested to know whether it works for other people or they get the same result as you.

Mh … What I do not understand. When I press the letter "a" normally while writing, the system makes an "a". Of course, what else? The "a" is typed when the key is down, not up (released).

If I press "a" and hold it, this menu appears
image

Isn't this exactly the same short/long press action? Why does this work here without interference?