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

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

Exactly. Or to put it another way: You can see the action happen. Then you release the key.

There are apps that offer a slightly absurd additional option. Long press when releasing. You can set up several long press actions.

So, hold for 1 second and release = action 1.
Hold for between 1 and 2 seconds and release = action 2
Hold for between 2 and 3 seconds and release = action 3

Theoretically, you only need one key for the whole alphabet. :rofl:

If you want that, fine. Otherwise I don't see any advantages. :man_shrugging: That's why I'm curious to see what @troy says.

1 Like

OK, so something else is going on for you.

Are other macros triggering? Perhaps you have something that is sending spurious USB events?

Sure - If I choose, I can follow the long press with other modifiers to trigger various other macros.
a small .1 or .2 delay after release and I can tap the modifier of choice.
ie. Long Tap followed by Control or Long Tap followed by Option etc. etc.
This approach is not reasonably possible when the Long Tap is triggered after a certain 'time out'. Your timing would have to be perfect. =)

But I also do use the nice macro that @noisneil has developed, that has the long tap triggering after a certain 'time out'.

I use both of them for different approaches.

Thank you, @troy. Not sure I understand. You press and hold eg ⌥a, then press and hold ⌘ and then release all keys together?

I use a Kensington Expert Mouse that has 4 buttons. I primarily us it and modifier keys as my triggers. It's quicker than modifier + key combinations since I don't have to move my hands.

To use your example of ⌥a.

I long press ⌥a then release, there is then a .15 sec delay in my macro.
If no other modifier key is pressed in that time then it executes the ⌥a + no modifier section.
But I can press ⌃ within the .15 sec and run the ⌃ section of the macro, or press ⌥ within the .15 sec and run the ⌥ section of the macro etc etc.

The grid is extensive and works great for me.