Skip to content

Commit 1106633

Browse files
committed
fix: clear modifier flags on typed text events on macOS
A new keyboard event takes its flags from the source's private state, which can still count a released modifier as held. Text typed after a Command shortcut then arrived as further Command shortcuts.
1 parent d227064 commit 1106633

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎src/platform/macos/MacKeyboardBackend.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ std::expected<void, Error> MacKeyboardBackend::typeUnicode(
101101
CGEventKeyboardSetUnicodeString(
102102
up, static_cast<UniCharCount>(len), utf16.data()
103103
);
104+
// A new event's default flags come from the source's private state, which
105+
// can still count a released modifier as held, so they are cleared here.
106+
CGEventSetFlags(down, 0);
107+
CGEventSetFlags(up, 0);
104108
CGEventPost(kCGHIDEventTap, down);
105109
CGEventPost(kCGHIDEventTap, up);
106110
CFRelease(down);

0 commit comments

Comments
 (0)