'How can you make the output of a key dependent on the duration which it is pressed. (in ahk, Autohotkey)
Basically what I want is the F9 key to be transformed into Ctrl+W when it is pressed for under 500ms and into Esc for any duration above 500ms. Thx
Solution 1:[1]
$F9::
Keywait, F9, T0.5 ; waits 0.5 seconds maximally for F9 to be released
if ErrorLevel ; pressed for above that time
Send ^w
else
Send {Esc}
Return
or
$F9::
Keywait, F9, T0.5 ; waits 0.5 seconds maximally for F9 to be released
if ErrorLevel ; pressed for above that time
{
KeyWait, F9 ; wait for F9 to be released
Send ^w
}
else
Send {Esc}
Return
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
