I am trying to use autohotkey to add an artificial delay to a keypress. I am in a tiled room, with a mechanical keyboard, and a desktop microphone. I would like to add an artificial delay of approximately 1/10 of a second to my PTT key, so that others don't hear the audible CLICK when I press the key. I ended up binding the key to something else "numpad -" so that capslock could be the key I actually press. This is the script I ended up with.
Expected result: pressing capslock presses numpad- on a 0.1s delay, and then holds the key until I release capslock(and it should also unpress capslock on release)
Actual result: It works, but if I press and release it too quickly, it holds "numpad -" down and capslock down, and releases neither.
code:
#UseHook
*~Capslock::
sleep, 100
Send {NumpadSub Down}
sleep, 100
While GetKeyState("Capslock")
{
}
return
*~Capslock Up::
sleep, 300
Send {NumpadSub Up}
return
without the sleeps as is, the program opens the key, closes the key, and then re-opens.