-
Notifications
You must be signed in to change notification settings - Fork 0
/
autohotkey.ahk
52 lines (41 loc) · 1.34 KB
/
autohotkey.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!h::Send, #{Left}
#!j::Send, #{Down}
#!k::Send, #{Up}
#!l::Send, #{Right}
#!+h::Send, #+{Left}
#!+j::Send, #+{Down}
#!+k::Send, #+{Up}
#!+l::Send, #+{Right}
;=======================================================================================================================
; CAPS-UNLOCKED
;=======================================================================================================================
; This is a complete solution to map the CapsLock key to Control and Escape without losing the ability to toggle CapsLock
;
; * Use CapsLock as Escape if it's the only key that is pressed and released within 300ms (configurable)
; * Use CapsLock as LControl when used in conjunction with some other key or if it's held longer than 300ms
; * Toggle CapsLock by pressing LControl+CapsLock
#InstallKeybdHook
SetCapsLockState, alwaysoff
StartTime := 0
*Capslock::
if (GetKeyState("LControl", "P")) {
KeyWait, CapsLock
Send {CapsLock Down}
return
}
Send {LControl Down}
State := (GetKeyState("Alt", "P") || GetKeyState("Shift", "P") || GetKeyState("LWin", "P") || GetKeyState("RWin", "P"))
if (!State && (StartTime = 0)) {
StartTime := A_TickCount
}
KeyWait, CapsLock
Send {LControl Up}
if (State) {
return
}
elapsedTime := A_TickCount - StartTime
if ((A_Priorkey = "CapsLock") && (elapsedTime < 300)) {
Send {Esc}
}
StartTime := 0
return