Keyboard shortcuts: configure different functionality for long or short presses

You need at least BetterTouchTool version 3.766 to do this

To setup a shortcut that triggers one function on short press, and another on long press do it like this:

For Long Press:

For Short Press:

Thanks!
Would it be possible to create a long-press variant out of a standard shortcut without creating an infinite loop?

Currently i have cmd-alt-c as shortcut for the following:

  1. send cmd-C (to copy selected text to clopboard)
  2. execute shell script "pbpaste | /usr/local/bin/jq | pbcopy" to format JSON and put back to clipboard

It sould be awesome to execute the above via long press cmd-C.
I cannot find any other way to "copy to clipboard" than actually sending a cmd-C.

Not exactly what you want. But, how about the key sequence cmd+c+c to „copy selected text to clipboard" and "execute shell script“? No infinite loop if you record this way.

Alternatively, just use "c". But you have to set up two actions.

Short pressed, c = c, 0 - 0.2 s, enable "Prevent recursive triggers"

and

Long pressed, c, any action, 0.25 s or longer.

This works well if you don't write too fast.

Hi @Andreas_Hegenberg,

thanks for the great feature! I have a question about Trigger on Key Up action - what's the recommended way to set unlimited Maximum hold time?

That's my use-case:

  • Trigger on Key Up between 0s-1s to trigger short press action (toggle mic: mute / unmute)
  • Trigger on Key Down from 1s to trigger entry long press action (push to talk: unmute mic)
  • Trigger on Key Up between 1s-unlimited to trigger exit long press action (push to talk: mute mic)

@Andreas_Hegenberg

I played a bit with the configuration and found some issues with Minimum hold time. I exported a preset and found out that:

  • for the below action:
    image
    I get:

    "BTTTriggerConfig" : {
      "BTTKeyboardShortcutMaxTime" : 0.25
    }
    

    so it seems fine.

  • for that one:
    image
    I get:

    "BTTTriggerConfig" : {
      "BTTKeyboardShortcutMinTime" : 0
    }
    

    so the value is not preserved.

  • for that one:
    image
    I get:

    "BTTTriggerConfig" : {
      "BTTKeyboardShortcutMinTime" : 0,
      "BTTKeyboardShortcutMaxTime" : 3600
    }
    

    so BTTKeyboardShortcutMaxTime is correct, but BTTKeyboardShortcutMinTime is again not preserved.

    PS After saving the above and re-opening, BTTKeyboardShortcutMaxTime value displays as 10 s:
    image
    but in config it's still fine (so 3600 s).

1 Like

@Andreas_Hegenberg This issue regarding BTTKeyboardShortcutMinTime becoming stuck at 0 seems to still be present in the latest version (3.837).

Should be fixed in the next alpha later today!

FYI: Just opened a potential bug related to min/max hold times here:

Issue: the short press doesn't work. Only the long press is registered. The "trigger on key up" only works when "Maximum time keys can be pressed" is set to 0, which will cause long press and short press to be both triggered.

Anything special about your shortcut? In general this should work fine. Maybe post a few screenshots or an export of the problematic shortcuts, then I can have a look.

Yeah sure it's attached to this reply, thanks for taking a look.

BTW, sometimes (and only sometimes, which is unpredictable) some shortcuts wouldn't work if they're in a conditional group (I use it like a folder, it only has one condition that is always met, like "mouse behind notch is 0" when my mac doesn't have a notch), but if I move them to All Apps they would work.

exported_triggers.bttpreset (3.4 KB)

This export only contains one shortcut, correct? It is set to trigger on key up if it has not been pressed for more than 0.4 seconds. That seems to work correctly here - doesn't it in your case?

I'd recommend to not use CAG's as folders as they always have some overhead. Better use real folders to organize shortcuts. The notch feature might lead to unexpected results on systems without notch :slight_smile:
If absolutely needed, use the custom variables as they are only evaluated on change:

@Andreas_Hegenberg
works fine, but not very convenient
it would be nice if this could be done without releasing key, just with long press
press "space" key for 2 sec and something happens
but seems like there is no such a trigger (
is it possible to achieve such a behaviour ?

found one more problem
when something assigned to button all other key combos stop working, ie option + space or something else

This is exactly what long press should do. This "something" happens while the key is held. For short press you would have to release the key in less than 2 seconds.

@Frank1 trigger on key up means that it happens when you hold at least X seconds and release, not just hold

Hold for at least 2 seconds, then release. No?

that was the question
how to trigger when it is held, not when released

But you won't be able to use your space key anymore then.Could in theory be worked around using an additional key sequence that triggers on space down and sends a "space key down" event:


I'll then better stay with caps + key
ty