Reputation: 105
Here is my script. Capslock is mapped to send Left control on long press,otherwise send an escape. This is working as expected.
SetCapsLockState, alwaysoff
Capslock::
Send {LControl Down}
KeyWait, CapsLock
Send {LControl Up}
if ( A_PriorKey = "CapsLock" ){
Send {Esc}
}
return
; Send left control when long pressed, otherwise behave a normal enter key
Enter::
send {LControl Down}
KeyWait, Enter, T5
Send {LControl Up}
if ( A_PriorKey = "Enter" ){
Send {Enter}
}
return
However Enter key is not waiting for the long press, it is timing out quickly.This is not my expectation. It should behave like the above snippet
Upvotes: 0
Views: 1225
Reputation: 2431
If I'm understanding the issue correctly, this should do what you require:
Enter::
SendInput, {LCtrl Down}
Sleep, 100
KeyWait, Enter
SendInput, {LCtrl Up}
if ( A_PriorKey = "Enter" ){
Send {Enter}
}
return
Also, I assume you have the catch at the end to pass through a single Enter keystroke. If that isn't the case, and you're wanting to pass through all of them (while Enter is held down), the following will accomplish that.
~Enter::
SendInput, {LCtrl Down}
Sleep, 100
KeyWait, Enter
SendInput, {LCtrl Up}
return
Upvotes: 1