Created
August 19, 2023 04:53
-
-
Save chuckadams/9f0d8ae3b67cf64297de458b19c9b716 to your computer and use it in GitHub Desktop.
hyper key for autohotkey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv ; recommended for performance and compatibility with future | |
autohotkey releases. | |
#UseHook | |
#InstallKeybdHook | |
#SingleInstance force | |
SendMode Input | |
;; deactivate capslock completely | |
SetCapslockState, AlwaysOff | |
;; remap capslock to hyper | |
;; if capslock is toggled, remap it to esc | |
;; note: must use tidle prefix to fire hotkey once it is pressed | |
;; not until the hotkey is released | |
~Capslock:: | |
;; must use downtemp to emulate hyper key, you cannot use down in this case | |
;; according to https://autohotkey.com/docs/commands/Send.htm, | |
downtemp is as same as down except for ctrl/alt/shift/win keys | |
;; in those cases, downtemp tells subsequent sends that the key is | |
not permanently down, and may be | |
;; released whenever a keystroke calls for it. | |
;; for example, Send {Ctrl Downtemp} followed later by Send {Left} | |
would produce a normal {Left} | |
;; keystroke, not a Ctrl{Left} keystroke | |
Send {Ctrl DownTemp}{Shift DownTemp}{Alt DownTemp}{LWin DownTemp} | |
KeyWait, Capslock | |
Send {Ctrl Up}{Shift Up}{Alt Up}{LWin Up} | |
if (A_PriorKey = "Capslock") { | |
Send {Esc} | |
} | |
return | |
;; vim navigation with hyper | |
~Capslock & h:: Send {Left} | |
~Capslock & l:: Send {Right} | |
~Capslock & k:: Send {Up} | |
~Capslock & j:: Send {Down} | |
;; popular hotkeys with hyper | |
~Capslock & c:: Send ^{c} | |
~Capslock & v:: Send ^{v} | |
Ctrl/Esc key | |
SetCapsLockState Off | |
CapsLock:: | |
key= | |
Input, key, B C L1 T1, {Esc} | |
if (ErrorLevel = "Max") | |
Send {Ctrl Down}%key% | |
KeyWait, CapsLock | |
Return | |
CapsLock up:: | |
If key | |
Send {Ctrl Up} | |
else | |
if (A_TimeSincePriorHotkey < 1000) | |
Send, {Esc 2} | |
Return | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment