AutoHotkey: Key Syntax

By Xah Lee. Date: . Last updated: .

Simple Modifier Key and Letter Key Combination on Left-Hand-Side

KeySyntax
Alt!
Ctrl^
Shift+
Win Logo#

Example. Left-Hand-Side, Combine Modifier Keys

#Requires AutoHotkey v2.0
; example of simple modifier plus letter key combo, on left-hand-side

; Ctrl+F6
^F6::send "hi"

; Ctrl+Alt+n
^!n::send "hi"

; Alt+n
!n::send "hi"

; Ctrl+n
^n::send "hi"

; Shift+n
+n::send "hi"

; Win+n
#n::send "hi"

Example. Copy Browser URL

#Requires AutoHotkey v2.0

; copy url
F7::
{
Send "^l"
Sleep 100
Send "^c"
Sleep 100
}

Full Modifier Keys Syntax

these are useful when you want to define a modifier key by itself, without combining other keys.

KeySyntax
left Windows logoLWin
right Windows logoRWin
ControlControl
left ControlLControl
right ControlRControl
ShiftShift
left ShiftLShift
right ShiftRShift
AltAlt
left AltLAlt
right AltRAlt
Menu KeyAppsKey

Example. Combine Modifier Keys

Example. Key combination on the right-hand-side

#Requires AutoHotkey v2.0
; make right Ctrl do Ctrl+Alt+Shift+9
RControl::Send "^!+9"

Example. Modifier keys combination on the left-hand-side

#Requires AutoHotkey v2.0
F7 & F8::Run "Notepad"
#Requires AutoHotkey v2.0
; make Ctrl+F5 do Ctrl+t
Control & F5::Send ("^t")

; switch to next window and hide current. Alt+Esc
LWin & F7::Send "!{Esc}"

; switch to previous window. Alt+Shift+Esc
LWin & F8::Send "!+{Esc}"

Action on Press or Release

If your script defines actions for any of Shift, Alt, Ctrl, they fire upon release of the key.

To make them fire on press, put a tilde in front, like this: ~Alt.

A specific left or right hotkey such as LAlt:: fires when it is pressed down.

#Requires AutoHotkey v2.0
; disable Win key behavior of popping up the Start Menu, but still allow Win+key combination.
~LWin::Send("{Blind}{vkE8}")
~RWin::Send("{Blind}{vkE8}")

Function Keys

#Requires AutoHotkey v2.0
; F1 key
F1::Run "Notepad"

; Ctrl+F1
^F1::Run "Notepad"

Space, Tab, Enter, Escape

KeySyntax
spaceSpace
tabTab
enterEnter
escapeEsc
backspaceBackspace
#Requires AutoHotkey v2.0
; Space key
Space::Run "Notepad"

; Ctrl+Space
^Space::Run "Notepad"

Home, End, Ins, Del, Page Up/Down

KeySyntax
deleteDel
insertIns
homeHome
endEnd
page upPgUp
page downPgDn

Arrow Keys

KeySyntax
Up
Down
Left
Right

Pause, Print Screen, Screen Lock, Capslock

KeySyntax
ScrLkScrollLock
CapsLockCapsLock
PrtScn/SysRqPrintScreen
Pause/BreakPause

If you want Ctrl+Pause, use the syntax ^CtrlBreak.

Numberpad Keys

KeySyntax
Num LockNumLock

Keys When Number Lock is On

KeySyntax
0Numpad0
1Numpad1
2Numpad2
3Numpad3
4Numpad4
5Numpad5
6Numpad6
7Numpad7
8Numpad8
9Numpad9
+NumpadAdd
/NumpadDiv
.NumpadDot
*NumpadMult
-NumpadSub
EnterNumpadEnter

Keys When Number Lock is Off

KeySyntax
EndNumpadEnd
HomeNumpadHome
PgDnNumpadPgDn
PgUpNumpadPgUp
DelNumpadDel
InsNumpadIns
NumpadLeft
NumpadRight
NumpadUp
NumpadDown

Multimedia Special Keys

The following are syntax for special buttons on many of today's keyboards.

Syntax
Browser_Back
Browser_Forward
Browser_Refresh
Browser_Stop
Browser_Search
Browser_Favorites
Browser_Home
Volume_Mute
Volume_Down
Volume_Up
Media_Next
Media_Prev
Media_Stop
Media_Play_Pause
Launch_Mail
Launch_Media
Launch_App1
Launch_App2
Sleep

Mouse

ButtonSyntax
leftLButton
rightRButton
scroll wheelMButton
Forward (4th button)XButton1
Backward (5th button)XButton2

Mouse Wheel

WheelSyntax
scroll wheel upWheelUp
scroll wheel downWheelDown
mouse wheel left pushWheelLeft
mouse wheel right pushWheelRight