Skip to content

Instantly share code, notes, and snippets.

@sbmthakur
Last active July 16, 2018 15:29
Show Gist options
  • Save sbmthakur/1f3550c4fe2995b6af7e535e2e3cc637 to your computer and use it in GitHub Desktop.
Save sbmthakur/1f3550c4fe2995b6af7e535e2e3cc637 to your computer and use it in GitHub Desktop.
Use Caps Lock as Escape and Control on Windows(quite useful when using Vim on Windows)
/* Following script enables mappings for Escape and Caps Lock.
This has been shamelessly copied from: http://vim.wikia.com
Source: http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows#Use_the_Caps_Lock_key_as_Ctrl
*/
SetCapsLockState Off
state:=false
; Use Esc as CapsLock
/* Uncomment the mapping if Caps Lock functionality is desired and you are okay with using Escape as Caps Lock
Esc::
state:= not state
if (state) {
SetCapsLockState On
} else {
SetCapsLockState Off
}
Return
*/
; Use Caps Lock as Control when pressed and held
; Use Caps Lock as Escape when pressed and released quickly(within 1 second)
; This mapping nicely when using Vim
*CapsLock::
Send {LControl down}
Return
*CapsLock up::
Send {LControl Up}
if (A_PriorKey=="CapsLock"){
if (A_TimeSincePriorHotkey < 1000)
Suspend On
Send, {Esc}
Suspend Off
}
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment