Skip to content

Instantly share code, notes, and snippets.

@Hoekstraa
Created December 8, 2024 16:39
Show Gist options
  • Save Hoekstraa/530b2ccd5d5aec6cce6df881296b1280 to your computer and use it in GitHub Desktop.
Save Hoekstraa/530b2ccd5d5aec6cce6df881296b1280 to your computer and use it in GitHub Desktop.
dual function keys on Windows
#Requires AutoHotkey v2.0
#SingleInstance
#MaxThreadsPerHotkey 3
; https://www.autohotkey.com/boards/viewtopic.php?style=19&t=92738
escih := InputHook("B L1 T1", "{Esc}")
entih := InputHook("B L1 T1", "{Enter}")
*CapsLock::
{
escih.Start()
reason := escih.Wait()
if (reason = "Stopped") {
Send "{Blind}{Esc}"
} else if (reason = "Max") {
Send "{Blind}{Ctrl down}" escih.Input
}
}
*CapsLock up::
{
if (escih.InProgress) {
escih.Stop()
} else {
Send "{Ctrl up}"
}
}
*Enter::
{
entih.Start()
reason := entih.Wait()
if (reason = "Stopped") {
Send "{Blind}{Enter}"
} else if (reason = "Max") {
Send "{Blind}{Ctrl down}" entih.Input
}
}
*Enter up::
{
if (entih.InProgress) {
entih.Stop()
} else {
Send "{Ctrl up}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment