How to remap a key on my keyboard depending on whether it was quickly pressed or held down for a second or more?
I got a new keyboard (Keychron K6), and long story short, I'd like to have my Esc key only be mapped to Esc when I hold it for a second. If I just tap it like a normal keystroke, I need to have it be the backtick/tilde key instead.
So:
- Press Esc: Result in ~
- Hold down Esc for a second: Result in Esc
I've looked at the Keyboard Manager tool on PowerToys and also fiddled a bit with AutoHotKey, and both of them seem very powerful but none of them seem to be able to consider whether a key is being held down or briefly pressed.
Is this even possible?
Cheers!
Solution 1:
Just tried this out, this AutoHotKey script should work
$esc::
KeyWait,esc,T0.5 ;wait 0.5 seconds for release key
If (ErrorLevel) ;more than 0.5 sec have passed
{
Send {esc}
keyHeld = 1
KeyWait,esc
}
Return
$esc up::
If (keyHeld = 0) ;If not held down
Send ``
Else
keyHeld = 0
Return
shift & esc::
Send ~
keyHeld = 1
Return