"Only on the first/second/third tap" with USB Device Key Trigger

I've been trying to get this to work with some of the programmable buttons on my Logitech G604 Mouse, but with no luck so far.

Just to make sure I understand, I should be able to set up a macro that's triggered when a programmable button is pressed only once, then a different macro that's triggered when the same button is pressed only twice, etc.?

Or am I misunderstanding this new trigger functionality?

Give this a try:

1 Like

Thanks, @noisneil. These look really clever. I'll give them a shot.

I'm still curious, though. Is this not more or less what the new “only on the first/second/third tap” trigger options are supposed to do?

I'll be honest: that slipped by me at release! Brilliant that KM has proper multi-press functionality now!

Yes, it's basically the same, except that my templates are tweakable, and therefore slightly more responsive, as far as I can tell. You also only have to set two triggers to get access to single, multiple or short/long presses all at once.

@peternlewis is the ~1sec lag with multiple taps due to allowances for slower tappers? If so, is there a global preference for that to make it a bit snappier?

3 Likes

I support that. Setting the time individually seems important to me. And what I have never understood: Why is long press not triggered when the key is down? Wouldn't that be more intuitive? If I'm not mistaken, this is the case in @noisneil's macro. You should also be able to set this time. So, if the key is hold longer than x seconds.

2 Likes

You'll be pleased to know that I'm revisiting the templates and, unless I'm mistaken, I think I've come up with a pretty major workflow enhancement for them... One I should have thought of long ago.

2 Likes

You make me curious, but you don't tell me anything. :rofl:

But I can tell you how I imagine it as a beginner.

Example:
⌘+1. After the "1" is up, KM waits a certain amount of time (adjustable) until the action is executed.
⌘+1+1. Is triggered when the time between "1" and "1" is undershot.
⌘+1 long press. Is triggered if "1" remains pressed for a minimum time. Trigger on key down, so that you can see how the action is executed.

Yes.

They are controlled by the double click interval. They can be down for at most the double click interval and up for at most twice that. For an "only" to fire, they must be up for at leas twice the double click interval before the trigger can fire.

You can override the times with the MaxTapDownTime and MaxTapUpTime preferences as documented.

2 Likes

I just tried this and it doesn't seem to make things any snappier.

defaults write com.stairways.keyboardmaestro.engine MaxTapDownTime -float 0.2
defaults write com.stairways.keyboardmaestro.engine MaxTapUpTime -float 0.2

I expected this to result in the gap between the last tap and actions being run to be reduced, but that doesn't seem to be the case. Evidently, I've misunderstood something.

Did you restart the engine?

I did, but I just tried again and this time it worked! Much better at 0.2s, I think.

I have to agree with @Frankb that long press should trigger once the time threshold has elapsed rather than upon release. Far more intuitive.

As things stand, I think the only real advantages of my template are that you can add unlimited tap numbers (not that I can imagine wanting more than three), the long press behaviour is arguably better and the tap speed can be defined by the user.

I've added an updated and improved version at the top here:

1 Like

Technically more than 3 is supported (up to 10), but it's not even documented.

defaults write com.stairways.keyboardmaestro.engine MaxTapsShowInEditor -int 7
1 Like

Thanks, Peter. Is there any reason why this wouldn't be working when trying with my Logitech G604 Mouse?

For example, I created Macro A to launch App A when Button X "is tapped only once." And then I created Macro B to launch App B when Button X "is tapped only twice." Neither macro is working. (However, either macro works just fine when the trigger is set back to "is pressed.")

No idea. Does it work when it is set to just tapped?

So it works for "is pressed" and "is tapped."

But it does not work for "is tapped once/twice/etc." or "is tapped only once/twice/etc.."

I prefer the long press to trigger on release.

Do you get the same behaviour if you use a key on the keyboard? Say Shift or Control or something like that?

I played around with it with my keyboard, and basically none of the options work reliably or at all.

The "is pressed" option sometimes required the key to be pressed multiple times before it worked.

The "is long pressed" option triggered the macro the moment the key was pressed, not requiring it to be held down at all.

The "is tapped once," "is tapped only once," etc. options still mostly didn't work.

(That was with my external keyboard, but I also tried it with my MacBook Pro keyboard, which I never use, and even there I was getting similar results, or the lack thereof.)

Could you explain why?

1 Like

In the meantime, I'll state the obvious by saying that the reason I prefer the other behaviour is that you can hold the key for as long as you like and be sure it will trigger, which also reduces the chance that you'll release it too early.

2 Likes