How to "toggle" key if held down for a second, but still work normally?

Hi, I have some disability issues I'm trying to use BTT to address. I'd like to make some "smart" toggle keys, meaning that tap the trigger key it will activate the target key up/down, but if I hold the trigger key for a second, it will hold the target key down again forever until it's tapped again. I can do one or the other, but haven't figured out how to do both.

Scenarios:

  1. Key "W" is pressed and released, acts normally
  2. If key "W" is held for > 1 second, it's "locked" on, and releasing it will still be held down
  3. If key "W" is pressed again while "auto hold" is on, it will just turn off auto hold
  4. If key "S" is pressed, it will disable auto hold on "W"

I've tried to do this with variables, and it seems to mostly work, except that BTT keeps popping up a context menu asking me which one to trigger, even though the two triggers have conditions, and then it also won't shut off. Here's what I have so far:

  1. W on key down, if "AUTO_HOLD_U" != "ON", minimum hold time 1s -> Set value "ON" for "AUTO_HOLD_U"
  2. W on key down, if "AUTO_HOLD_U" != "ON" -> trigger U on key down
  3. W on key down, if "AUTO_HOLD_U" == "ON" -> trigger U on key up
  4. W on key up, if "AUTO_HOLD_U" != "ON" -> trigger U on key up
  5. S on key down, if "AUTO_HOLD_U" == "ON" -> turn off "AUTO_HOLD_U" and trigger U key up

Problems:

  1. W will not immediately activate U, it will wait until a second has passed and then pop up a context menu asking which one I want to run, but I want to do both, and don't want to be asked
  2. I also need to be able to use keys like S, A, D to "turn off" AUTO_HOLD_U but also still pass through the key press.

If I can make this work where I can either tap or toggle a key, it will literally be life changing for my ability to use the computer, so any suggestions are greatly appreciated. Thank you for reading.