Can I press one time or two times the same key to get different triggers with
"Key Sequences / Typed Words"?
Thanks!
I know that my question is not very interesting but I am not too smart.
I have the same question - can we make it so that pressing F6 once yields one action but double press yields another.
Just Create 2 Separate Triggers
One for F6 = Whatever
One for F6 F6 = Whatever
Have you tried it with Key Sequences / Typed Words?
An obvious approach is to use key sequences for this, yes. But in this case ("F6 once" and "F6 twice" as separate key sequences 1 and 2) only "F6 once" actually works. "F6 twice" never triggers.
What me and i assume @main.caparisi want is to have 2 different actions assigned to the same key – depending on how many times it is pressed.
Having only double press OR single press per key works perfectly fine for me.
To use the F6 function once, simply go to "Keyboard Shortcuts". For the double-click F6 function, use sequences instead. I've been able to do this without any problems. Hope it works for you too!
EDIT: Is "Trigger on Key Up" activated?
I've tried that, but in this case the double-click F6 invokes the one-click F6 action too. Which makes sense, since key sequences don't block regular BTT shortcuts.
In my specific case, what I'm trying to achieve:
- pressing F6 once activates Apple Music window;
- pressing F6 twice 'loves' the current song in the background without activating the window.
problem is, for this to be really useful, BTT would need some way to wait for x amount of time after the first f6 was pressed - and only trigger the action if no other f6 appears during that time.
It's a good idea, and I should be able to add this. Currently you'd need some scripting to make that work. Maybe I can post an example script tomorrow.
Maybe I didn't understand something. But why not just use two shortcuts? F6 short/long press?
If it must be a key sequence, then like this
F6 (short)
F6 (long)
@Frank1 I think sometimes a quick double press can feel better / more reliable than a long press. I think that's just personal preference (or even another way to trigger a third action with the same key ;-).
Here is an example script you can use to make this work. Assign the "Run Real JavaScript" action to a shortcut (not key sequence) in BTT and paste this script.
It will trigger the named trigger defined in line 2, when doing a single press. It will trigger the named trigger you defined in line 3 when doing a double press. It will wait for 0.5 seconds before executing the single press - to see whether a double press will happen - that time can be changed by modifying line 4.
The named triggers need to be defined in the "Automations, Named & Other Triggers" section in BTT - you can assign any action to them.
(async () => {
let singleTapNamedTrigger = 'SingleTap'; // trigger on single press
let doubleTapNamedTrigger = 'DoubleTap'; // trigger on double press
let delay = 0.5; // time to wait for second press
// no modifications necessary from here
let now = Date.now() / 1000;
let lastTrigger = await callBTT('get_number_variable', {
variable_name: 'last_key_trigger_time',
});
if (now - lastTrigger < delay) {
callBTT('cancel_delayed_named_trigger_execution', {
trigger_name: singleTapNamedTrigger,
});
callBTT('trigger_named_async_without_response', {
trigger_name: doubleTapNamedTrigger,
wait_for_reply: false,
});
} else {
callBTT('trigger_named_async_without_response', {
trigger_name: singleTapNamedTrigger,
wait_for_reply: false,
delay: delay
});
}
callBTT('set_number_variable', {
variable_name: 'last_key_trigger_time',
to: now,
});
returnToBTT('done');
})();
Of course I just wanted to mention that because it's not clear to me if that's clear to everyone.
And longer than 0.1 s for long press is not really long and does not need scripts
do you see a chance to implement this?
"I think the key sequences feature would would need (in addition to the "max pause between key presses") a "minimum pause between key preses" and additionaly a way to to match a range (or all) keys. Both could be nice additions in general, I'll check whether I can add this."
unfortunately I haven't started working on that yet, but I still think it would be a good feature