Skip to content

[KeyboardManager] Ctrl becomes permanently stuck after pressing AltGr when shortcut remap uses LCtrl #46693

@fluffyspace

Description

@fluffyspace

Microsoft PowerToys version

0.98.1

Installation method

WinGet

Running as admin

No

Area(s) with issue?

Keyboard Manager

Steps to reproduce

  1. Configure a global shortcut remap that uses Left Ctrl as a modifier (e.g. LCtrl+Y → Backspace)
  2. Press and release AltGr (Right Alt) at any time without triggering a shortcut remap — for example, just tap AltGr while in a text editor, or type an AltGr character like @ on a German keyboard layout
  3. Now press LCtrl+Y to trigger the configured shortcut

✅ Expected behavior

The shortcut fires and Ctrl is properly released after the shortcut completes. Subsequent keyboard input works normally.

❌ Actual behavior

After step 2, the LCtrl key becomes permanently stuck. The shortcut remap stops cleaning up properly — Ctrl appears held down even after releasing all keys. All subsequent key presses behave as if Ctrl is held. The only workaround is to restart the Keyboard Manager module.

Root cause

In KeyboardEventHandlers.cpp, the static bool isAltRightKeyInvoked flag (line 303) is set to true when AltGr is pressed (RAlt while LCtrl is held), but it is only reset inside Case 1's else branch (lines 653, 677), which requires isShortcutInvoked == true. If AltGr is pressed and released when no shortcut is active, the flag stays true permanently.

Once the flag is stale:

  • Modifier key restoration is skipped at 13 locations (all guarded by if (!isAltRightKeyInvoked))
  • Shortcut state (isShortcutInvoked) is never reset
  • LCtrl key-up events are consumed by a break statement (line 620-622) instead of being properly handled

This affects any shortcut remap that uses LCtrl as a modifier, since the line 620 guard specifically checks for VK_LCONTROL.

Other Software

None relevant — this is reproducible with just Keyboard Manager and any keyboard layout that has an AltGr key (or by pressing Right Alt on any layout).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Product-Keyboard Shortcut ManagerIssues regarding Keyboard Shortcut ManagerduplicateThis label was added by a GitHub action and this issue may be a potential duplicate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions