Bug when using min/max hold time for keys configured with the same trigger key

Describe the bug

I have 3 shortcuts assigned to B (see details in 'additional information' below):

  • Long-Press (key down, min hold 1 sec): set isBLongPressed = true
  • Short-Press 1 (key up, min hold 1 sec, no max hold): set isBLongPressed = false
  • Short-Press 2 (key up, no min hold, max hold 0.99sec): send B key and set isBLongPressed = false

As well as one 'Long-Press-Modifier' trigger (see details in 'additional information' below) that should only activate when I press 1 while isLongPressed == true.

I would expect that:

  • when I just type a b normally, that only 'Short-Press 2' would trigger (which seems to work properly :white_check_mark:)
  • when I press-hold b for 1sec or longer, 'Long-Press' would trigger (which seems to work properly :white_check_mark:), and then when I release it, only 'Short-Press 1' would trigger (which doesn't seem to work properly :x:)

It seems that:

  • if I press and hold b long enough to trigger 'Long-Press' :white_check_mark:, then release it, neither 'Short-Press 1' or 'Short-Press 2' are triggered :x:
  • if I press and hold b long enough to trigger 'Long-Press' :white_check_mark:, press 1 to trigger the 'Long-Press-Modifier' trigger :white_check_mark:, and quickly release the keys, then the 'Long-Press-Modifier' action runs :white_check_mark:, but then 'Short-Press 2' runs :x: (I would have expected 'Short-Press ' to run in this instance)
  • if I press and hold b long enough to trigger 'Long-Press' :white_check_mark:, press/release 1 to trigger the 'Long-Press-Modifier' trigger :white_check_mark:, but then wait a while until I release the b key, I would have expected 'Short-Press 1' to trigger, but nothing runs :x:
  • if I press 1 when isLongPressed != true, the trigger shouldn't run :white_check_mark:, but it also shouldn't prevent a normal 1 from being typed :x:

Affected input device (e.g. MacBook Trackpad, Magic Mouse/Trackpad, Touch Bar, etc.):
Magic Keyboard / N/A

Screenshots
If applicable, add screenshots to help explain your problem. (You can just paste or drag them here)

Device information:

  • Type of Mac: MacBook Pro, 16-inch, 2019
  • macOS version: Ventura 13.1 (22C65)
  • BetterTouchTool version: Version 3.952 (2117)

Additional information (e.g. StackTraces, related issues, screenshots, workarounds, etc.):

Long-Press:

image

image

Short-Press 1:

image

image

Short-Press 2:

image

image

'Long-Press-Modifier' trigger:

image

As requested on the other thread:

Here are the definitions for the 4 triggers:

[
  {
    "BTTTriggerConditionsReadOnly" : "isBLongPressed == \"true\"",
    "BTTTriggerConditions" : "YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMSAAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGvEBYLDBMYICorLTQ4PT5BRUlOT1JaXmJkVSRudWxs0w0ODxAREl8QF05TQ29tcG91bmRQcmVkaWNhdGVUeXBlXxAPTlNTdWJwcmVkaWNhdGVzViRjbGFzcxABgAKAFdIUDxUXWk5TLm9iamVjdHOhFoADgBTUDxkaGxwdHh9fEBFOU1JpZ2h0RXhwcmVzc2lvbl8QEE5TTGVmdEV4cHJlc3Npb25fEBNOU1ByZWRpY2F0ZU9wZXJhdG9ygBOADoAEgBHVISIjJA8lJicoKVlOU09wZXJhbmReTlNTZWxlY3Rvck5hbWVfEBBOU0V4cHJlc3Npb25UeXBlW05TQXJndW1lbnRzgAaABRADgAiADVx2YWx1ZUZvcktleTrSIw8QLIAH0i4vMDFaJGNsYXNzbmFtZVgkY2xhc3Nlc18QEE5TU2VsZkV4cHJlc3Npb26jMDIzXE5TRXhwcmVzc2lvblhOU09iamVjdNIUDzU3oTaACYAM0w8jOTo7PFlOU0tleVBhdGiACxAKgApeaXNCTG9uZ1ByZXNzZWTSLi8_QF8QHE5TS2V5UGF0aFNwZWNpZmllckV4cHJlc3Npb26jPzIz0i4vQkNeTlNNdXRhYmxlQXJyYXmjQkQzV05TQXJyYXnSLi9GR18QE05TS2V5UGF0aEV4cHJlc3Npb26kRkgyM18QFE5TRnVuY3Rpb25FeHByZXNzaW9u00ojD0tMTV8QD05TQ29uc3RhbnRWYWx1ZYAPEACAEFR0cnVl0i4vUFFfEBlOU0NvbnN0YW50VmFsdWVFeHByZXNzaW9uo1AyM9UPU1RVVldMWExZWk5TTW9kaWZpZXJYTlNOZWdhdGVZTlNPcHRpb25zXk5TT3BlcmF0b3JUeXBlgBIIEATSLi9bXF8QG05TRXF1YWxpdHlQcmVkaWNhdGVPcGVyYXRvcqNbXTNfEBNOU1ByZWRpY2F0ZU9wZXJhdG9y0i4vX2BfEBVOU0NvbXBhcmlzb25QcmVkaWNhdGWjX2EzW05TUHJlZGljYXRl0i4vRGOiRDPSLi9lZl8QE05TQ29tcG91bmRQcmVkaWNhdGWjZWEzAAgAEQAaACQAKQAyADcASQBMAFEAUwBsAHIAeQCTAKUArACuALAAsgC3AMIAxADGAMgA0QDlAPgBDgEQARIBFAEWASEBKwE6AU0BWQFbAV0BXwFhAWMBcAF1AXcBfAGHAZABowGnAbQBvQHCAcQBxgHIAc8B2QHbAd0B3wHuAfMCEgIWAhsCKgIuAjYCOwJRAlYCbQJ0AoYCiAKKAowCkQKWArICtgLBAswC1QLfAu4C8ALxAvMC+AMWAxoDMAM1A00DUQNdA2IDZQNqA4AAAAAAAAACAQAAAAAAAABnAAAAAAAAAAAAAAAAAAADhA==",
    "BTTTriggerType" : 0,
    "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
    "BTTPredefinedActionType" : 254,
    "BTTPredefinedActionName" : "Show HUD Overlay",
    "BTTHUDActionConfiguration" : "{\"BTTActionHUDDetail\":\"isBLongPressed was true, so we trigger our 'custom modifier' based shortcut!\",\"BTTActionHUDTitle\":\"B1 Shortcut Triggered\",\"BTTActionHUDDuration\":5,\"BTTActionHUDBackground\":\"38.719535, 38.720697, 38.720067, 213.662109\",\"BTTActionHUDSlideDirection\":0}",
    "BTTAdditionalConfiguration" : "0",
    "BTTEnabled2" : 1,
    "BTTKeyboardShortcutKeyboardType" : 1118,
    "BTTRepeatDelay" : 0,
    "BTTUUID" : "4763F1B2-AD46-48A0-B874-3AE524A0512F",
    "BTTTriggerOnDown" : 1,
    "BTTNotesInsteadOfDescription" : 0,
    "BTTLayoutIndependentChar" : "1",
    "BTTEnabled" : 1,
    "BTTModifierMode" : 0,
    "BTTShortcutKeyCode" : 18,
    "BTTShortcutModifierKeys" : 0,
    "BTTOrder" : 0,
    "BTTDisplayOrder" : 0,
    "BTTAutoAdaptToKeyboardLayout" : 0
  },
  {
    "BTTGestureNotes" : "Set isBLongPressed on key down after delay (min hold 1 sec)",
    "BTTTriggerType" : 0,
    "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
    "BTTPredefinedActionType" : 292,
    "BTTPredefinedActionName" : "Assign Value to Variable",
    "BTTVariableName" : "isBLongPressed",
    "BTTVariableValue" : "true",
    "BTTActionURLToLoad" : "isBLongPressed",
    "BTTActionFloatingHTMLConfig" : "true",
    "BTTAdditionalConfiguration" : "0",
    "BTTEnabled2" : 1,
    "BTTKeyboardShortcutScope" : 0,
    "BTTKeyboardShortcutKeyboardType" : 1118,
    "BTTRepeatDelay" : 0,
    "BTTUUID" : "F4C3088A-794A-4B45-8C7D-1A2A57F8CB42",
    "BTTTriggerOnDown" : 1,
    "BTTNotesInsteadOfDescription" : 0,
    "BTTLayoutIndependentChar" : "b",
    "BTTEnabled" : 1,
    "BTTModifierMode" : 0,
    "BTTShortcutKeyCode" : 11,
    "BTTShortcutModifierKeys" : 0,
    "BTTOrder" : 1,
    "BTTDisplayOrder" : 0,
    "BTTAutoAdaptToKeyboardLayout" : 0,
    "BTTAdditionalActions" : [
      {
        "BTTGestureNotes" : "Long-press B (1)",
        "BTTTriggerType" : 0,
        "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
        "BTTPredefinedActionType" : 254,
        "BTTPredefinedActionName" : "Show HUD Overlay",
        "BTTHUDActionConfiguration" : "{\"BTTActionHUDDetail\":\"\",\"BTTActionHUDTitle\":\"B Long Pressed\",\"BTTActionHUDDuration\":5,\"BTTActionHUDBackground\":\"38.719535, 38.720697, 38.720067, 213.662109\",\"BTTActionHUDSlideDirection\":0}",
        "BTTAdditionalConfiguration" : "0",
        "BTTEnabled2" : 1,
        "BTTKeyboardShortcutScope" : 0,
        "BTTKeyboardShortcutKeyboardType" : 1118,
        "BTTRepeatDelay" : 0,
        "BTTUUID" : "1E764C6E-A041-4D34-9FD8-A912500E4246",
        "BTTTriggerOnDown" : 1,
        "BTTNotesInsteadOfDescription" : 0,
        "BTTLayoutIndependentChar" : "b",
        "BTTEnabled" : 1,
        "BTTModifierMode" : 0,
        "BTTShortcutKeyCode" : 11,
        "BTTShortcutModifierKeys" : 0,
        "BTTOrder" : 0,
        "BTTDisplayOrder" : 0,
        "BTTAutoAdaptToKeyboardLayout" : 0,
        "BTTAdditionalActions" : [
          {
            "BTTTriggerType" : -1,
            "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
            "BTTPredefinedActionType" : 292,
            "BTTPredefinedActionName" : "Assign Value to Variable",
            "BTTVariableName" : "isBLongPressed",
            "BTTVariableValue" : "true",
            "BTTActionURLToLoad" : "isBLongPressed",
            "BTTActionFloatingHTMLConfig" : "true",
            "BTTEnabled2" : 1,
            "BTTKeyboardShortcutKeyboardType" : 0,
            "BTTRepeatDelay" : 0,
            "BTTUUID" : "DFF5D248-6DF1-4689-9A34-4ABAD60EBA70",
            "BTTNotesInsteadOfDescription" : 0,
            "BTTEnabled" : 1,
            "BTTModifierMode" : 0,
            "BTTShortcutKeyCode" : -1,
            "BTTShortcutModifierKeys" : -1,
            "BTTOrder" : 33,
            "BTTDisplayOrder" : 0,
            "BTTAutoAdaptToKeyboardLayout" : 0
          }
        ],
        "BTTTriggerConfig" : {
          "BTTKeyboardPreventRecursiveTriggers" : 1,
          "BTTKeyboardShortcutMinTime" : 1
        }
      }
    ],
    "BTTTriggerConfig" : {
      "BTTKeyboardPreventRecursiveTriggers" : 1,
      "BTTKeyboardShortcutMinTime" : 1
    }
  },
  {
    "BTTGestureNotes" : "Unset isBLongPressed on key up (min hold 1sec, no max)",
    "BTTTriggerType" : 0,
    "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
    "BTTPredefinedActionType" : 292,
    "BTTPredefinedActionName" : "Assign Value to Variable",
    "BTTVariableName" : "isBLongPressed",
    "BTTVariableValue" : "false",
    "BTTActionURLToLoad" : "isBLongPressed",
    "BTTActionFloatingHTMLConfig" : "false",
    "BTTAdditionalConfiguration" : "0",
    "BTTEnabled2" : 1,
    "BTTKeyboardShortcutScope" : 0,
    "BTTKeyboardShortcutKeyboardType" : 1118,
    "BTTRepeatDelay" : 0,
    "BTTUUID" : "D65E9FB3-41D4-4009-80F9-C71F86A69845",
    "BTTTriggerOnDown" : 0,
    "BTTNotesInsteadOfDescription" : 0,
    "BTTLayoutIndependentChar" : "b",
    "BTTEnabled" : 1,
    "BTTModifierMode" : 0,
    "BTTShortcutKeyCode" : 11,
    "BTTShortcutModifierKeys" : 0,
    "BTTOrder" : 2,
    "BTTDisplayOrder" : 0,
    "BTTAutoAdaptToKeyboardLayout" : 0,
    "BTTTriggerConfig" : {
      "BTTKeyboardPreventRecursiveTriggers" : 1,
      "BTTKeyboardShortcutMinTime" : 1,
      "BTTHUDText" : "Short-Press 1",
      "BTTShowHUD" : 1
    }
  },
  {
    "BTTGestureNotes" : "Send standard 'B' on shortpress, and unset isBLongPressed (no min hold, max 0.99sec",
    "BTTTriggerType" : 0,
    "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
    "BTTPredefinedActionType" : -1,
    "BTTPredefinedActionName" : "No Action",
    "BTTLayoutIndependentActionChar" : "b",
    "BTTAutoAdaptActionToKeyboardLayout" : true,
    "BTTShortcutToSend" : "11",
    "BTTAdditionalConfiguration" : "0",
    "BTTEnabled2" : 1,
    "BTTKeyboardShortcutScope" : 0,
    "BTTKeyboardShortcutKeyboardType" : 1118,
    "BTTRepeatDelay" : 0,
    "BTTUUID" : "B869A4D2-6663-4DB3-87D2-E8CAAF0011EC",
    "BTTTriggerOnDown" : 0,
    "BTTNotesInsteadOfDescription" : 0,
    "BTTLayoutIndependentChar" : "b",
    "BTTEnabled" : 1,
    "BTTModifierMode" : 0,
    "BTTShortcutKeyCode" : 11,
    "BTTShortcutModifierKeys" : 0,
    "BTTOrder" : 3,
    "BTTDisplayOrder" : 0,
    "BTTAutoAdaptToKeyboardLayout" : 0,
    "BTTAdditionalActions" : [
      {
        "BTTTriggerType" : 0,
        "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
        "BTTPredefinedActionType" : 292,
        "BTTPredefinedActionName" : "Assign Value to Variable",
        "BTTVariableName" : "isBLongPressed",
        "BTTVariableValue" : "false",
        "BTTActionURLToLoad" : "isBLongPressed",
        "BTTActionFloatingHTMLConfig" : "false",
        "BTTAdditionalConfiguration" : "0",
        "BTTEnabled2" : 1,
        "BTTKeyboardShortcutScope" : 0,
        "BTTKeyboardShortcutKeyboardType" : 1118,
        "BTTRepeatDelay" : 0,
        "BTTUUID" : "E6A187AC-C143-436F-80F7-B23A616DF0C4",
        "BTTTriggerOnDown" : 0,
        "BTTNotesInsteadOfDescription" : 0,
        "BTTLayoutIndependentChar" : "b",
        "BTTEnabled" : 1,
        "BTTModifierMode" : 0,
        "BTTShortcutKeyCode" : 11,
        "BTTShortcutModifierKeys" : 0,
        "BTTOrder" : 0,
        "BTTDisplayOrder" : 0,
        "BTTAutoAdaptToKeyboardLayout" : 0,
        "BTTAdditionalActions" : [
          {
            "BTTTriggerType" : -1,
            "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut",
            "BTTPredefinedActionType" : -1,
            "BTTPredefinedActionName" : "No Action",
            "BTTLayoutIndependentActionChar" : "b",
            "BTTAutoAdaptActionToKeyboardLayout" : true,
            "BTTShortcutToSend" : "11",
            "BTTEnabled2" : 1,
            "BTTKeyboardShortcutKeyboardType" : 0,
            "BTTRepeatDelay" : 0,
            "BTTUUID" : "494EFFBB-C943-4506-969F-3005C8CD3F17",
            "BTTNotesInsteadOfDescription" : 0,
            "BTTEnabled" : 1,
            "BTTModifierMode" : 0,
            "BTTShortcutKeyCode" : -1,
            "BTTShortcutModifierKeys" : -1,
            "BTTOrder" : 35,
            "BTTDisplayOrder" : 0,
            "BTTAutoAdaptToKeyboardLayout" : 0
          }
        ],
        "BTTTriggerConfig" : {
          "BTTKeyboardPreventRecursiveTriggers" : 1
        }
      }
    ],
    "BTTTriggerConfig" : {
      "BTTKeyboardPreventRecursiveTriggers" : 1,
      "BTTKeyboardShortcutMaxTime" : 0.99000000953674316,
      "BTTHUDText" : "Short-Press 2",
      "BTTShowHUD" : 1
    }
  }
]

Ah that case is not handled currently. You can work around it by adding a very long maximum hold time for Short-Press 1.

However the general setup is pretty problematic, isn't it? You won't really be able to type anything that contains the b letter as the keys will get mixed up if you type too fast.

1 Like

Are you able to expand on what aspect of it "isn't handled currently"? And how setting that very long max hold time for 'Short-Press 1' works around that?

Yeah, that is the tiny edge case; though in playing around with it just now it doesn't actually seem to happen all that often. In reality I would probably also not assign it to a key used as frequently as b, maybe to a lesser used number key or similar. I was more interested in exploring how to make the concept of it work, then would figure out which key I could use it with that wouldn't impact me later on.

I mean the "setting a minimum hold time of 1, but at the same time having a maximum hold time of 0". These two will conflict, thus the Short-Press-1 will never be called in your setup.
So just setting the maximum hold time to something very large will solve the issue.

It should ignore the maximum hold time if it hasn't changed / is zero, but this is not implemented right now.

1 Like

Ah, ok, that makes sense. I was assuming that a max hold time of 0 would have just disabled the max all together. Though the workaround makes sense in the meantime.

It seems like the max hold time that I can set (even with manually editing the value) is 10 seconds; which should be long enough that I never hit it in most standard cases.

Is that an enhancement that could be made?

could be made, but it's currently not very high on my TODO list :wink:
I'll show a note if a trigger is configured like this, that will be easy to do without touching the logic.

1 Like

Haha, totally understandable.

Awesome, that works! :slight_smile:


So I just tried setting 'Short-Press 1's max hold time to 10sec, and now when I press and hold b :white_check_mark: , then tap 1 it triggers my 'Long-Press-Modifier' action :white_check_mark:; but if I release b quickly, it's still firing 'Short-Press 2' :x:.

In that same scenario, if I release b slowly (eg. keep holding it for a while) after pressing 1, then 'Short-Press 1' is triggered as expected. :white_check_mark:

It seems that 'Short-Press 1's 'hold time' is being reset/counted from when I press the 1 :x:; not from when I originally started to press and hold b as I would have expected.

that's true, BTT records the time whenever a key down event occurs, and the time is not directly associated to a specific shortcut.

I'll need to look into this and check whether it can be changed.

1 Like

Thanks for looking into it :slight_smile:

@devalias just my two cents.

I'm afraid any configuration that types a letter (b) when a key is released will not make you happy. At least not if you can type fast.

Short/long press triggers are very handy, especially single key triggers (without modifiers). They work really well with BTT, but only if you reverse the default system (short = down, long = up).

BTT can automatically delete typed letters before triggering the long press action.

If you don't want a letter to be typed in a certain field at all, you can exclude this field with a conditional activation group.

I just used b as an example/proof of concept.. I would most likely choose some other less-used key for my actual shortcuts.

Why does reversing the default system make them better?

How would you set up a conditional activation group to prevent a letter being typed in a field?