Author Topic: Short Tap + Double Tap + Long Tap assigned to 1 key  (Read 1244 times)

Wave

  • Newbie
  • *
  • Posts: 3
Short Tap + Double Tap + Long Tap assigned to 1 key
« on: February 15, 2023, 12:14:26 AM »
Hi all,

Is it possible to assign 1 key to have 3 different actions, like so:

Short Tap Key: Action A
Double Tap Key: Action B
Long Tap Key: Action C

It works perfectly with Short and Double, or Short and Long. But Double and Long doesn't work together.

In the manual it says "Note that if you designate a key/key combination to a double tap as well as a long tap, conflicts will occur."

So is it possible to get around this issue somehow? Thankyou!


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Short Tap + Double Tap + Long Tap assigned to 1 key
« Reply #1 on: February 15, 2023, 12:52:00 AM »
It is possible, E.G. by using the built-in "Shortcut is invoked when pressed twice (double tap)" and "Invoke also on single press (Advanced)" options, and handling the hold functionality within the command itself:
Code: [Select]
Set date [~holdTimeout] to [~holdTimeout] plus [400] milliseconds
Begin Text Compare : [{CMDDOUBLETAPINVOKED}] Equals '0'
    Start Loop While :  Keyboard Key 'Ctrl' Is Pressed
        Begin Date Compare : [~holdTimeout] Is Before Current Date/Time
            Write [Blue] 'Hold' to log
        End Condition - Exit when condition met
    End Loop
    Write [Blue] 'Press' to log
Else
    Write [Blue] 'Double tap' to log
End Condition
Note that the value of ~holdTimeout would be in addition to the value you have set for the "Keyboard shortcut double tap threshold (ms)" option on the "Hotkeys" tab of the VoiceAttack options window (default is 300, so in this example, holding down the key for ~700ms would signify a hold)

The above should be "cleaner" than the alternative of using the built-in "Shortcut is invoked when long-pressed" and "Invoke also on short/standard press (Advanced)" options and implementing double-tapping within the command (or doing everything within the command without any built-in options), as it does not require any non command-scoped variables.

Wave

  • Newbie
  • *
  • Posts: 3
Re: Short Tap + Double Tap + Long Tap assigned to 1 key
« Reply #2 on: February 15, 2023, 05:52:32 AM »
Thanks a ton Pfeil - that worked absolutely flawlessly. Such a quick response too!

The only edit I made is lowering holdTimeout to be close to 0 milliseconds. I'm using the profile in a fast paced game and this makes it feel really snappy, while still keeping the mistakes to a minimum.

Love your work, cheers.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Short Tap + Double Tap + Long Tap assigned to 1 key
« Reply #3 on: February 15, 2023, 05:59:34 AM »
If you have no need for an additional delay on top of the double tap's delay, the command can be simplified:
Code: [Select]
Begin Text Compare : [{CMDDOUBLETAPINVOKED}] Equals '0'
    Begin Device State Check :  Keyboard Key 'Ctrl' Is Pressed
        Write [Blue] 'Hold' to log
    End Condition - Exit when condition met
    Write [Blue] 'Press' to log
Else
    Write [Blue] 'Double tap' to log
End Condition

Wave

  • Newbie
  • *
  • Posts: 3
Re: Short Tap + Double Tap + Long Tap assigned to 1 key
« Reply #4 on: February 15, 2023, 06:51:35 AM »
Yep that makes sense. I'll try this out next, thanks!