Skip to content

input(macOS): preserve Caps Lock key releases - #7840

Merged
osy merged 1 commit into
utmapp:mainfrom
lprazdnik:fix/caps-lock-release
Sep 2, 2026
Merged

input(macOS): preserve Caps Lock key releases#7840
osy merged 1 commit into
utmapp:mainfrom
lprazdnik:fix/caps-lock-release

Conversation

@lprazdnik

Copy link
Copy Markdown
Contributor

Summary

  • Preserve Caps Lock key-down and key-up events when “Caps Lock is treated as a key” is enabled.
  • Temporarily remap Caps Lock while guest input is captured and restore the host mapping afterward.
  • Prevent Caps Lock-based guest modifiers, such as NVDA commands, from remaining stuck after the key is released.

Resolves #7838

Testing

Tested by a human on a MacBook Pro with Apple M5 Max running macOS 26.6.2, using Windows 11 ARM as a QEMU guest with NVDA.

Verified repeated commands while Caps Lock remained held, normal input after releasing Caps Lock, and restoration of the host keyboard mapping after releasing VM input.

The author acknowledges that this change has been tested and/or reviewed by a human in accordance with UTM's AI contribution guidelines.

macOS treats Caps Lock as a locking modifier and never delivers its
physical release, so once "Caps Lock is treated as a key" is enabled a
guest that uses it as a held modifier (e.g. a screen reader's NVDA key)
never sees it let go.

While VM input is captured, remap Caps Lock to F20 on each attached
keyboard through IOHIDEventSystemClient (Apple TN2450) so macOS delivers
a normal key down/up pair, which VMMetalView translates back to the Caps
Lock scan code. The keyboard's previous mapping is put back when capture
ends, and a remap left behind by a crash is removed at the next launch.
F20 is the highest function key macOS delivers and is on no Apple
keyboard, so no physical key is shadowed.

Fixes utmapp#7838

Assisted-by: Codex:gpt-5
Assisted-by: Claude:claude-fable-5-1
@osy
osy force-pushed the fix/caps-lock-release branch from d8d9704 to 8f7a663 Compare September 1, 2026 22:00
@osy

osy commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@lprazdnik I've re-written the commit, can you re-test?

@osy osy added this to the v5.0 milestone Sep 1, 2026
@lprazdnik

Copy link
Copy Markdown
Contributor Author

I tested the latest commit with Windows 11 ARM and NVDA. Caps Lock works as expected, including repeated commands while held and normal input after release.

Thanks!

@osy
osy merged commit 8b13f49 into utmapp:main Sep 2, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Caps Lock remains held in guest after key is released

2 participants