Skip to content

BUG: Hotkey triggers with extra modifiers (Ctrl+Shift+D activates when only Ctrl+D is registered) #3

@Arezhik

Description

@Arezhik

Summary

The activation hotkey fires even if the user is holding additional modifier keys that are not part of the registered combination.
This makes the hotkey extremely prone to accidental activation.

Expected Behavior

The hotkey should only trigger when exactly the registered modifiers (and no extra modifiers) are pressed together with the main key.

Example (registered hotkey = Ctrl + D):

  • Ctrl + D → activates ✓ (correct)
  • Ctrl + Shift + D → should be ignored
  • Ctrl + Alt + D → should be ignored
  • Ctrl + Win + D → should be ignored
  • Ctrl + Shift + Alt + D → should be ignored

Actual Behavior

Any superset of the registered modifiers still triggers the overlay:

  • Ctrl + D → activates (correct)
  • Ctrl + Shift + D → activates (incorrect)
  • Ctrl + Alt + D → activates (incorrect)
  • Ctrl + Shift + Alt + D → activates (incorrect)
  • Ctrl + CapsLock + D → activates (incorrect)

Steps to Reproduce

  1. Set the global hotkey to Ctrl + D (or any combination that includes only some modifiers).
  2. Hold down an extra modifier that is not part of the registered combo (e.g. Shift, Alt, Win, CapsLock).
  3. Press D while still holding the extra modifier(s).
  4. → Overlay activates unexpectedly.

Environment

  • Windows 10

Additional Notes / Likely Root Cause from AI

This is the classic mistake when using RegisterHotKey() or when manually checking modifiers in a keyboard hook:

  • RegisterHotKey() automatically ignores extra modifiers by design → if you're seeing this bug, the app is not using RegisterHotKey() and is instead implementing its own low-level hook.
  • In a low-level keyboard hook, developers often check only (GetAsyncKeyState(VK_CONTROL) & 0x8000) and similar for the expected modifiers, without verifying that unwanted modifiers (Shift, Alt, Win) are not pressed.

Correct implementation requires an explicit mask check, e.g.:

bool extraModifiers = (GetAsyncKeyState(VK_SHIFT)   & 0x8000) ||
                      (GetAsyncKeyState(VK_MENU)    & 0x8000) ||
                      (GetAsyncKeyState(VK_LWIN)    & 0x8000) ||
                      (GetAsyncKeyState(VK_RWIN)    & 0x8000);
if (extraModifiers) return; // ignore

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions