Skip to content
Y
yTube.SITE v8.0.4
media / worlds / tools / internet oddities
YouTube / video information

How to Make AutoHotkey v2 Scripts Work While Holding Shift Key

Video information, playback and saved actions.

How to Make AutoHotkey v2 Scripts Work While Holding Shift Key

Description: Learn how to modify AutoHotkey v2 scripts so your hotkeys trigger even when holding the Shift key, perfect for gaming scenarios.
---
This video is based on the question https://stackoverflow.com/q/78838576/ asked by the user 'user24974510' ( https://stackoverflow.com/u/24974510/ ) and on the answer https://stackoverflow.com/a/78920185/ provided by the user 'user24974510' ( https://stackoverflow.com/u/24974510/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.

Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: auto hot key v2: block of code does not execute when holding shift key

Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/licensing
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/by-sa/4.0/ ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/by-sa/4.0/ ) license.

If anything seems off to you, please feel free to drop me a comment under this video.
---
The Problem: Hotkeys Not Triggering When Holding Shift

When using AutoHotkey v2 for game-related scripts, you might notice that some hotkeys don’t execute properly if you are holding the Shift key (common for sprinting or running). For example, a script bound to XButton2 won’t activate unless you release Shift first — which is annoying during gameplay.

Why This Happens

By default, AutoHotkey treats modifier keys (Shift, Ctrl, Alt, etc.) as part of the hotkey combination. Thus, when Shift is held, your hotkey (like XButton2) is interpreted differently or blocked.

The Simple Fix: Use the * (Wildcard) Modifier

AutoHotkey’s wildcard * prefix tells the script to ignore the state of modifier keys when processing the hotkey. This means the hotkey will trigger regardless of whether Shift (or any other modifiers) are held.

How to Modify Your Hotkeys

Add * at the start of your hotkey declaration, like this:

[[See Video to Reveal this Text or Code Snippet]]

* = Wildcard, ignores modifiers

~ = Passes the key through to the active window (does not block original key behavior)

Example for Your x Key Hotkey

[[See Video to Reveal this Text or Code Snippet]]

Summary

Use the * wildcard with your hotkeys to ensure they execute even when Shift (or other modifiers) are held.

Keep the ~ modifier if you want to avoid blocking the original key’s default function.

This simple tweak allows your scripts to work seamlessly during games where sprinting or other movement involves holding Shift.



Feel free to test the updated hotkeys. This is a lightweight and elegant fix that works reliably across AutoHotkey v2 scripts. Close description
      
Videos related to "How to Make AutoHotkey v2 Scripts Work While Holding Shift Key"

Related videos are temporarily unavailable.

Try again, or come back later.