autohotkey

Prevent <modifier> & <key> hotkey from firing if the <key> is already held down?


I have this issue I have been unable to solve elegantly. I provided the below code as a reproducible sample

If I trigger shift + f23, then release shift but still holding down f23, if I press control, control + f23 fires. I am not expecting this behaviour and its undesired, I dont want control + f23 to fire if f23 is already down in the first place.

<^f23::
tooltip ctrl and f23 down
KeyWait, f23
tooltip ctrl and f23 up
return

<+f23::
tooltip shift and f23 down
KeyWait, f23
tooltip shift and f23 up
return

I have a lot of hotkeys like the above (<^f1 ... <^f22,, etc etc), so I am looking for one size fits all solution.


Solution

  • KeyWait:

    While the command is in a waiting state, new threads can be launched via hotkey, custom menu item, or timer.

    https://www.autohotkey.com/docs/v1/lib/KeyWait.htm#Remarks

    That is,