Skip to content

Instantly share code, notes, and snippets.

@binaryphile
Created August 28, 2012 16:54
Show Gist options
  • Save binaryphile/3500552 to your computer and use it in GitHub Desktop.
Save binaryphile/3500552 to your computer and use it in GitHub Desktop.
Autohotkey use Esc as modifier script
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
; This script uses Esc as a modifier key so that the keyboard can be used for directional keys (arrows, etc.)
; without needing to move hands much. My Esc key is in the position normally occupied by right-alt (for easy
; use in vim), so you could do this on your keyboard without the need for the toggle logic. However, if you
; want to use a non-modifier key (such as Esc) as a modifier, this will do the trick. Just substitute your
; desired key for Esc.
;
; The movement keys I chose here are in the inverted-T position like normal arrows. The position of my Esc (right-
; alt) is such that it's easiest to shift my right hand one key to the right so the positioning relative to Esc is
; natural and doesn't tweak my thumb.
;
; Since I occasionally hit the Esc as modifier and then think better of it, I sometimes end up sending an Esc as
; a result. To stop this from happening, I put a timeout on the release of the Esc key so it only sends Esc if you
; tap it, not hold it. Releasing after a hold of longer than 1/5 second sends nothing.
;
; The script does not interfere with using other modifiers with Esc.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Toggle := False
$*Esc::
Toggle := True
KeyWait, Esc, T0.2 ; Adjust this value to change the delay between switching modes
If NOT ErrorLevel
Send {Blind}{Esc}
Return
#If Toggle
Esc UP::Toggle := False
; Movement Keys
u::PgUp
i::Up
o::PgDn
h::Home
j::Left
k::Down
l::Right
`;::End
BS::Delete
; Bottom left - acts as Control for common shortcuts
f::^f
s::^s
z::^z
x::^x
c::^c
v::^v
r::^r
a::^a
w::^w
#If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment