Oh ok. I haven't messed with these settings for years but presumably you set it to 0.5 for 0.5s.
Have you tried this and found that it doesn't work? If not, give it a go.
Oh ok. I haven't messed with these settings for years but presumably you set it to 0.5 for 0.5s.
Have you tried this and found that it doesn't work? If not, give it a go.
Set which one to 0.5? There are two different numbers. That's what is confusing to me. I don't quite get what each of the two numbers do? If one of these variables was labeled as something like "long press interval", or something like that, it would be fairly self explanatory.. but both of these two different variables make reference to tap values, so I'm not sure what to do with these.
As for just trying it out, it's a long story, but I have your old macros pretty heavily intertwined with other macros I've created, so it's not a simple matter to untangle them. And, if I just "play with the numbers" to see what happens, it wouldn't necessarily be 100% clear that things were or weren't changing in response to my experimentation with changing those values in Terminal.
Bottom line, I want to make sure that I understand how to change these numbers, and what their effect on the trigger behavior is, before I go and start trying to switch over from your long press triggers to the native long press triggers. If you're not aware of how to change these numbers, that's cool. But Peter or somebody ought to be able to explain how to change these numbers to get the desired long press interval. I just need a clear understanding of how these values work, before I go and make any changes, that way I can trust that any irregularity isn't due to an incorrect understanding of how those two values change things in Terminal and KM.
It sounds to me like you want a definitive answer, not one determined by testing. I'm in the same boat as you ("confused"), I would have to test, and I'm not sure that testing is going to be helpful to you. It sounds like you want only the official answer. That's your prerogative. In that case, some of us can't help.
Sorry, my bad. I was at a BBQ today and reading on my phone. I didn't notice that the scripts refer to taps rather than long press. Yes, it is a little confusing. I'm sure @peternlewis can clarify.
Yeah, I'm thinking Peter will have to jump in to clarify, as I'm not sure that anyone else knows for sure how those scripts work. Thanks anyway.
The default amount of time a key must be down to be considered a long press is the double click interval on your Mac (controlled in the system settings (presumably still, Apple has changed System Settings a lot).
You can configure a specific time with the command:
defaults write com.stairways.keyboardmaestro.engine MaxTapDownTime -float 1.0
Time is in seconds, so that would require the key to be pressed and held down for at least a second and then released to trigger a long press.
If you want to trigger on either and know which, you can use a macro that triggers on tap
and long pressed
and check the Trigger token for containing long
. Note that you must use tapped
and not pressed
in this test - pressed
will trigger immediately the key is pressed, where as tapped
and long pressed
(which really should be long tapped
) will trigger on the release of the key - one or the other will trigger always, never both.
And it sounds like the default long press time is 1.0 seconds, correct? Also, to be clear, I'm not talking about hot keys. I'm talking about buttons on my Stream Deck, if that matters.
I'll give this a shot. Thanks
The same timing applies for Hot Key and USB Device Key triggers.
So if you are using the first party Keyboard Maestro plugin with Stream Deck, then the same timing applies since it works via the USB Device Key trigger. If you are using KM Link
, then the behaviour of that is controlled by the plugin and I don't know its workings.
I'm still confused then, because if the long press timing is based on how the double click interval is set on your Mac, then what is the purpose of changing things in Terminal?
The "1.0" shown below, at the end of the command line is why I was asking if that was meant to be some kind of default of 1.0 seconds.
defaults write com.stairways.keyboardmaestro.engine MaxTapDownTime -float 1.0
The default is the double click interval, or you can configure it explicitly in the Terminal using the command, in which case it will be whatever you configure it to.
The 1.0 shown is the example time. The default time is the double click interval which is what is used if there is no setting for that preference.
That's very useful, thank you!
Is there a way to have long press trigger when the interval is reached, rather than on release?
The current method is useful in some cases, but in others leaves me guessing whether I've held the key long enough. Example: I want to hold a key to bring up a palette
I've been pondering your question for an hour. I'm very close to solving your request, using a ten line macro, but I have a question. When you say "rather than on release" I think what you mean is two things:
(1) you want the palette to appear if the button is held down for (let's say, for the sake of discussion) one second; AND ALSO...
(2) you want the palette to appear if the button is held down less than one second but then released.
Am I correct? You want the palette to appear if EITHER the button is held down for one second (even if not released) OR the button is released in less than one second.
If I am correct then the wording of your statement is not accurate, when you said "rather than on release" because you still want the macro to trigger on release if the duration of the button press is quite short.
If I'm correct, then what do you want if the button is released after (for example) 100 seconds, even though the palette was displayed 99 seconds ago. Do you want KM to remember that the palette was already triggered because of the one second timeout, and take NO action after the extra 99 seconds? I think that's what you want, and I think that's what my macro has accomplished.
Thank you for looking into it! Yes, that is more accurate statement of what I want.
My Muti-Press submacro does exactly this.
Then he should use your macro. My macro does trigger on the two conditions he wanted, but it also triggers on two other conditions, which are not what he wanted. If I can get my macro debugged, I will post it for comparison purposes.
I ended up continuing to use your macro for the long press, because I wanted to maintain the ability have it trigger after a set time instead of waiting until I lifted my finger. The native can't do that, unfortunately, so that continues to be an advantage that your macro has.
Also, I was never having timing issues between the long press on your macro and my macros that I was triggering with your long press. It was the short press on your macro that I was having timing issues with, when trying to use the short press on your macro to trigger some macros. I never did quite figure out what the issue was.
In any case, my solution was to use your macro for triggering other macros in a long press scenario and to use the KM native short press for triggering other macros in a short press scenario. Best of both worlds.
Just checking... Are you using the new submacro version or the old one that had all the press detection in a template?
No, the trigger happens on release and either tap or long press is triggered.
Peter is always right, but he meant within the built-in features of Keyboard Maestro. With a little programming, almost anything is possible with Keyboard Maestro. I've just written a macro that seems to work. During my initial tests, this does exactly what you are asking for. If not, let me know.
It is able to detect if the button is pressed and held for one second (you can change that value, of course. For my testing purposes one second was a good test value.) If the button is released in less than one second, the macro speaks the word "Released" (and you can change that action, of course.) If the button is held for longer than one second, the macro speaks the word "Held down" (and you can change that too, of course.) From what you've told me, you want the same thing to occur in each case, so you can either create a macro that is called by this macro in those two places, or you can just duplicate your code in the two places in this macro.
You will also have to adjust the trigger to insert your own mouse button in there, as I have a different brand of mouse than you have.
Let me know if you have any problems with it. I tested it for five minutes, but that's no guarantee it will work for anyone else.
If Held for 1 second, do one thing, if released first, do a different thing Macro (v11.0.3)
If Held for 1 second- do one thing- if released first- do a different thing.kmmacros (11 KB)