List of Keys (Keyboard, Mouse and Controller)

Table of Contents

Mouse

General Buttons

Name Description
LButton Primary mouse button. Which physical button this corresponds to depends on system settings; by default it is the left button.
RButton Secondary mouse button. Which physical button this corresponds to depends on system settings; by default it is the right button.
MButton Middle or wheel mouse button

Advanced Buttons

Name Description
XButton1 4th mouse button. Typically performs the same function as Browser_Back.
XButton2 5th mouse button. Typically performs the same function as Browser_Forward.

Wheel

Name Description
WheelDown Turn the wheel downward (toward you).
WheelUp Turn the wheel upward (away from you).
WheelLeft
WheelRight

Scroll to the left or right.

These can be used as hotkeys with some (but not all) mice which have a second wheel or support tilting the wheel to either side. In some cases, software bundled with the mouse must instead be used to control this feature. Regardless of the particular mouse, Send and Click can be used to scroll horizontally in programs which support it.

Keyboard

Note: The names of the letter and number keys are the same as that single letter or digit. For example: b is B and 5 is 5.

Although any single character can be used as a key name, its meaning (scan code or virtual keycode) depends on the current keyboard layout. Additionally, some special characters may need to be escaped or enclosed in braces, depending on the context. The letters a-z or A-Z can be used to refer to the corresponding virtual keycodes (usually vk41-vk5A) even if they are not included in the current keyboard layout.

General Keys

Name Description
CapsLock CapsLock (caps lock key)

Note: Windows IME may interfere with the detection and functionality of CapsLock; see CapsLock and IME for details.

Space Space (space bar)
Tab Tab (tabulator key)
Enter Enter
Escape (or Esc) Esc
Backspace (or BS) Backspace

Cursor Control Keys

Name Description
ScrollLock ScrollLock (scroll lock key). While Ctrl is held down, ScrollLock produces the key code of CtrlBreak, but can be differentiated from Pause by scan code.
Delete (or Del) Del
Insert (or Ins) Ins
Home Home
End End
PgUp PgUp (page up key)
PgDn PgDn (page down key)
Up (up arrow key)
Down (down arrow key)
Left (left arrow key)
Right (right arrow key)

Numpad Keys

Due to system behavior, the following keys separated by a slash are identified differently depending on whether NumLock is ON or OFF. If NumLock is OFF but Shift is pressed, the system temporarily releases Shift and acts as though NumLock is ON.

Name Description
Numpad0 / NumpadIns0 / Ins
Numpad1 / NumpadEnd1 / End
Numpad2 / NumpadDown2 /
Numpad3 / NumpadPgDn3 / PgDn
Numpad4 / NumpadLeft4 /
Numpad5 / NumpadClear5 / typically does nothing
Numpad6 / NumpadRight6 /
Numpad7 / NumpadHome7 / Home
Numpad8 / NumpadUp8 /
Numpad9 / NumpadPgUp9 / PgUp
NumpadDot / NumpadDel. / Del
NumLock NumLock (number lock key). While Ctrl is held down, NumLock produces the key code of Pause, so use ^Pause in hotkeys instead of ^NumLock.
NumpadDiv / (division)
NumpadMult * (multiplication)
NumpadAdd + (addition)
NumpadSub - (subtraction)
NumpadEnter Enter

Function Keys

Name Description
F1 - F24 The 12 or more function keys at the top of most keyboards.

Modifier Keys

Name Description
LWin Left Win. Corresponds to the <# hotkey prefix.
RWin

Right Win. Corresponds to the ># hotkey prefix.

Note: Unlike Ctrl/Alt/Shift, there is no generic/neutral "Win" key because the OS does not support it. However, hotkeys with the # modifier can be triggered by either Win.

Control (or Ctrl) Ctrl. Corresponds to the ^ hotkey prefix. As a hotkey without a key-up counterpart (Control:: or Ctrl:: without Control up:: or Ctrl up::) it fires upon release unless it has the tilde prefix, and is not suppressed even if the prefix is absent. By contrast, a specific left or right hotkey such as LCtrl:: fires when it is pressed down.
Alt Alt. Corresponds to the ! hotkey prefix. As a hotkey without a key-up counterpart (Alt:: without Alt up::) it fires upon release unless it has the tilde prefix, and is not suppressed even if the prefix is absent. By contrast, a specific left or right hotkey such as LAlt:: fires when it is pressed down.
Shift Shift. Corresponds to the + hotkey prefix. As a hotkey without a key-up counterpart (Shift:: without Shift up::) it fires upon release unless it has the tilde prefix, and is not suppressed even if the prefix is absent. By contrast, a specific left or right hotkey such as LShift:: fires when it is pressed down.
LControl (or LCtrl) Left Ctrl. Corresponds to the <^ hotkey prefix.
RControl (or RCtrl) Right Ctrl. Corresponds to the >^ hotkey prefix.
LShift Left Shift. Corresponds to the <+ hotkey prefix.
RShift Right Shift. Corresponds to the >+ hotkey prefix.
LAlt Left Alt. Corresponds to the <! hotkey prefix.
RAlt

Right Alt. Corresponds to the >! hotkey prefix.

Note: If your keyboard layout has AltGr instead of RAlt, you can probably use it as a hotkey prefix via <^>! as described here. In addition, LControl & RAlt:: would make AltGr itself into a hotkey.

Multimedia Keys

The function assigned to each of the keys listed below can be overridden by modifying the Windows registry. This table shows the default function of each key on most versions of Windows.

Name Description
Browser_Back Back
Browser_Forward Forward
Browser_Refresh Refresh
Browser_Stop Stop
Browser_Search Search
Browser_Favorites Favorites
Browser_Home Homepage
Volume_Mute Mute the volume
Volume_Down Lower the volume
Volume_Up Increase the volume
Media_Next Next Track
Media_Prev Previous Track
Media_Stop Stop
Media_Play_Pause Play/Pause
Launch_Mail Launch default e-mail program
Launch_Media Launch default media player
Launch_App1 Launch This PC (formerly My Computer or Computer)
Launch_App2 Launch Calculator

Other Keys

Name Description
AppsKey Menu. This is the key that invokes the right-click context menu.
PrintScreen PrtSc (print screen key)
CtrlBreak Ctrl+Pause or Ctrl+ScrollLock
Pause Pause or Ctrl+NumLock. While Ctrl is held down, Pause produces the key code of CtrlBreak and NumLock produces Pause, so use ^CtrlBreak in hotkeys instead of ^Pause.
Help Help. This probably doesn't exist on most keyboards. It's usually not the same as F1.
Sleep Sleep. Note that the sleep key on some keyboards might not work with this.
SCnnn Specify for nnn the scan code of a key. Recognizes unusual keys not mentioned above. See Special Keys for details.
VKnn

Specify for nn the hexadecimal virtual key code of a key. This rarely-used method also prevents certain types of hotkeys from requiring the keyboard hook. For example, the following hotkey does not use the keyboard hook, but as a side-effect it is triggered by pressing either Home or NumpadHome:

^VK24::MsgBox "You pressed Home or NumpadHome while holding down Control."

Known limitation: VK hotkeys that are forced to use the keyboard hook, such as *VK24 or ~VK24, will fire for only one of the keys, not both (e.g. NumpadHome but not Home). For more information about the VKnn method, see Special Keys.

Warning: Only Send, GetKeyName, GetKeyVK, GetKeySC and A_MenuMaskKey support combining VKnn and SCnnn. If combined in any other case (or if any other invalid suffix is present), the key is not recognized. For example, vk1Bsc001:: raises an error.

Keys Which Send a Combination

Some keyboards carry a key whose firmware does not report a code of its own, but instead sends a combination of ordinary keys. Two common examples:

Key Sends
Copilot LWin+LShift+F23
Office LCtrl+LShift+LAlt+LWin

These labels are not runtime key names. A script can always write the combination the key sends, exactly as it would for any other combination, and a keyboard which sends some other combination is handled the same way. Whether a key labelled Copilot or Office sends what the table shows depends on its firmware; use KeyHistory to see what a particular keyboard actually emits.

Copilot is also a Keysharp-specific convenience alias in static hotkey and remap declarations only. The compiler replaces a complete Copilot term with <#<+F23 before registering the hotkey. This includes either term of a custom combination and either side of a remap. There is no corresponding Office alias.

Examples

; A hotkey on the Copilot key.
Copilot::MsgBox "Copilot pressed"

; Remap the Copilot key to the menu key.
Copilot::AppsKey

; Make another key send what the Copilot key sends.
CapsLock::Copilot

; Remap it to RCtrl+A. Sided target modifiers are emitted correctly.
Copilot::>^a

; There is no Office alias; write its generic combination.
<^<+<!LWin::MsgBox "Office pressed"

Note: The alias does not apply to the runtime Hotkey function, Send, KeyWait, GetKeyState, InputHook, or the key-name query functions. For example, Send "{Copilot}" is not supported. Use the actual component keys with those APIs. A dynamic hotkey can use Hotkey("<#<+F23", Callback).

The < and > prefixes belong to hotkey syntax. Send does not recognize them and types them as ordinary characters, so Send "<#<+{F23}" does not send this combination. Write it with explicit key events, or use the plain #+ form, whose modifiers Send already resolves to the left-hand key:

Send "{LWin down}{LShift down}{F23}{LShift up}{LWin up}"
Send "#+{F23}"   ; Equivalent, since Send's modifiers are left-hand.

Because the trigger of the Office key is LWin, a hotkey on it affects a key the operating system also uses. Test such a hotkey before relying on it.

Holding one of these keys and pressing another

Which form to use depends on whether the combination consists only of modifiers.

Everything the Office key sends is a modifier, so holding it and pressing another key is an ordinary hotkey:

<^<+<!<#x::MsgBox "Office held, then x"

The Copilot key is different: it includes F23, which is not a modifier and so cannot be written in the modifier position. This needs a custom combination, whose prefix may carry modifiers of its own. The alias can be used for the complete prefix:

Copilot & x::MsgBox "Copilot held, then x"

In the combination form the modifiers are checked when the prefix key goes down, and that verdict is kept until it is released, so a modifier released while the prefix is still held does not cancel the combination. Pressing F23 without them does not make it a prefix at all, which leaves the plain key unaffected.

Modifiers are equally allowed on the suffix of a combination, where they are checked against the modifier state as the suffix is pressed:

a & Copilot::MsgBox "a held, then Copilot"

Caveats

A hotkey matches the combination, not the physical key. Copilot:: fires whenever LWin+LShift+F23 occurs, whether that came from the key, from the user pressing those keys, or from another script sending them. Nothing can distinguish these.

When Copilot is the source of a remap, its generated callbacks release the firmware-generated LWin and LShift as needed, but do not restore them after the target is released. Writing the literal <#<+F23 instead requests ordinary generic-chord behavior, including the normal restoration check. This distinction prevents the remap from manufacturing a bare modifier press while the Copilot firmware is completing its own release sequence.

Because the alias is replaced before registration, runtime values such as A_ThisHotkey use the canonical <#<+F23 spelling rather than Copilot.

Which side matters. These keys send left-hand modifiers, so <#<+ is required; the neutral #+ would also match the right-hand keys.

A custom combination requires the keyboard hook.

Game Controller (Gamepad, Joystick, etc.)

Note: For historical reasons, the following button and control names begin with Joy, which stands for joystick. However, they usually also work for other game controllers such as gamepads or steering wheels.

Joy1 through Joy32: The buttons of the controller. To help determine the button numbers for your controller, use this test script. Note that hotkey prefix symbols such as ^ (control) and + (shift) are not supported (though GetKeyState can be used as a substitute). Also note that the pressing of controller buttons always "passes through" to the active window if that window is designed to detect the pressing of controller buttons.

Although the following control names cannot be used as hotkeys, they can be used with GetKeyState:

For example, when using Xbox Wireless/360 controllers, JoyX/JoyY is the left stick, JoyR/JoyU the right stick, JoyZ the left and right triggers, and JoyPOV the directional pad (D-pad).

Multiple controllers: If the computer has more than one controller and you want to use one beyond the first, include the controller number (max 16) in front of the control name. For example, 2joy1 is the second controller's first button.

Note: If you have trouble getting a script to recognize your controller, specify a controller number other than 1 even though only a single controller is present. It is unclear how this situation arises or whether it is normal, but experimenting with the controller number in the controller test script can help determine if this applies to your system.

See Also:

Hand-held Remote Controls

Respond to signals from hand-held remote controls via the WinLIRC client script.

Special Keys

If your keyboard or mouse has a key not listed above, you might still be able to make it a hotkey by using the following steps:

  1. Ensure that at least one script is running that is using the keyboard hook. You can tell if a script has the keyboard hook by opening its main window and selecting "View->Key history" from the menu bar.
  2. Double-click that script's tray icon to open its main window.
  3. Press one of the "mystery keys" on your keyboard.
  4. Select the menu item "View->Key history"
  5. Scroll down to the bottom of the page. Somewhere near the bottom are the key-down and key-up events for your key. NOTE: Some keys do not generate events and thus will not be visible here. If this is the case, you cannot directly make that particular key a hotkey because your keyboard driver or hardware handles it at a level too low for AutoHotkey to access. For possible solutions, see further below.
  6. If your key is detectable, make a note of the 3-digit hexadecimal value in the second column of the list (e.g. 159).
  7. To define this key as a hotkey, follow this example:
    SC159::MsgBox ThisHotkey " was pressed." ; Replace 159 with your key's value.
    
    Also see ThisHotkey.

Reverse direction: To remap some other key to become a "mystery key", follow this example:

; Replace 159 with the value discovered above. Replace FF (if needed) with the
; key's virtual key, which can be discovered in the first column of the Key History screen.
#c::Send "{vkFFsc159}" ; See Send {vkXXscYYY} for more details.

Alternate solutions: If your key or mouse button is not detectable by the Key History screen, one of the following might help:

  1. Reconfigure the software that came with your mouse or keyboard (sometimes accessible in the Control Panel or Start Menu) to have the "mystery key" send some other keystroke. Such a keystroke can then be defined as a hotkey in a script. For example, if you configure a mystery key to send Ctrl+F1, you can then indirectly make that key as a hotkey by using ^F1:: in a script.

  2. Try AHKHID from the archived forum. You can also try searching the forum for a keywords like RawInput*, USB HID or AHKHID.

  3. The following is a last resort and generally should be attempted only in desperation. This is because the chance of success is low and it may cause unwanted side-effects that are difficult to undo:
    Disable or remove any extra software that came with your keyboard or mouse or change its driver to a more standard one such as the one built into the OS. This assumes there is such a driver for your particular keyboard or mouse and that you can live without the features provided by its custom driver and software.

CapsLock and IME

Some configurations of Windows IME (such as Japanese input with English keyboard) use CapsLock to toggle between modes. In such cases, CapsLock is suppressed by the IME and cannot be detected by AutoHotkey. However, the Alt+CapsLock, Ctrl+CapsLock and Shift+CapsLock shortcuts can be disabled with a workaround. Specifically, send a key-up to modify the state of the IME, but prevent any other effects by signalling the keyboard hook to suppress the event. The following function can be used for this purpose:

; The keyboard hook must be installed.
InstallKeybdHook
SendSuppressedKeyUp(key) {
    DllCall("keybd_event"
        , "char", GetKeyVK(key)
        , "char", GetKeySC(key)
        , "uint", KEYEVENTF_KEYUP := 0x2
        , "uptr", KEY_BLOCK_THIS := 0xFFC3D450)
}

After copying the function into a script or saving it as SendSuppressedKeyUp.ahk in a Lib folder and adding #Include <SendSuppressedKeyUp> to the script, it can be used as follows:

; Disable Alt+key shortcuts for the IME.
~LAlt::SendSuppressedKeyUp "LAlt"

; Test hotkey:
!CapsLock::MsgBox A_ThisHotkey

; Remap CapsLock to LCtrl in a way compatible with IME.
*CapsLock::
{
    Send "{Blind}{LCtrl DownR}"
    SendSuppressedKeyUp "LCtrl"
}
*CapsLock up::
{
    Send "{Blind}{LCtrl Up}"
}