Skip to content

Key Overrides: Fix Ghost Modifier Bug on macOS (with Karabiner Elements)#25886

Open
mellanslag-de wants to merge 1 commit intoqmk:masterfrom
mellanslag-de:patch-2
Open

Key Overrides: Fix Ghost Modifier Bug on macOS (with Karabiner Elements)#25886
mellanslag-de wants to merge 1 commit intoqmk:masterfrom
mellanslag-de:patch-2

Conversation

@mellanslag-de
Copy link

Description

Key Overrides seem to have a bug where sometimes Modifiers are pressed when not wanted, or not pressed when wanted.

This issue seems to already be known about and was partly fixed, judging by this line of code (also in the diff of this pr):

// On macOS there seems to be a race condition when it comes to the keyboard report and consumer keycodes. It seems the OS may recognize a consumer keycode before an updated keyboard report, even if the keyboard report is actually sent before the consumer key. I assume it is some sort of race condition because it happens infrequently and very irregularly. Waiting for about at least 10ms between sending the keyboard report and sending the consumer code has shown to fix this.
wait_ms(10);

But apparently, this wait does not fix the bug fully, judging by this issue #24688 and also by the bug I observed (describe in my comment to that issue #24688 (comment)), which is basically shift being held down, even though it should be suppressed.
To summarize it seems to happen rarely on macOS (judging by the quoted code comment above), and always for me and the issue creator when Karabiner Elements is used.

And QMK currently seems to handle/fix that edge case only for non-basic keycodes, not for basic ones.
And thats exactly what this PR addresses. I added the "send keyboard report with modifiers, then wait, only then send the key press" also in the case of basic key codes. I decided to then move it out of the if statement to reduce code duplication, with the downside of the printf now happening slightly later. I hope that's okay, else I can of course also move it back into the if statement by duplicating it to both branches.

But im not really into the inner workings of QMK, so I cant really judge whether its a good or appropriate fix, all i can say that this change makes it work for me :)

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@github-actions github-actions bot added the core label Dec 19, 2025
@mellanslag-de mellanslag-de changed the title Key Overrides: Fix Ghost Modifier Bug on macOS (and Karabiner Elements) Key Overrides: Fix Ghost Modifier Bug on macOS (with Karabiner Elements) Dec 19, 2025
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Thank you for your contribution!
This pull request has been automatically marked as stale because it has not had activity in the last 45 days. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, or re-open when it's ready.
For maintainers: Please label with bug, awaiting review, breaking_change, in progress, or on hold to prevent the issue from being re-flagged.

@github-actions github-actions bot added the stale Issues or pull requests that have become inactive without resolution. label Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core stale Issues or pull requests that have become inactive without resolution.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant