You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flutter does not receive key up events when cmd key is pressed (macOS) #38076
This has the effect of "sticking" keys in RawKeyboard.instance.keysPressed, which in turn causes the Shortcuts widget to fail.
After a bit of research, it might be worthwhile to send events directly from the NSApplication to the engine. Looks like everything passes through - sendEvent before it is interpreted and delegated to the various the NSResponder methods.
Any thoughts on approach Stuart? I had the thought that subclassing NSApplication might make integration into existing projects more difficult, but that could be outweighed by the value of dealing with the raw event stream.
Also, is the preference to do this work in Objective-C?
Just a quick update here. We managed to get around this with my suggestion above. I'm not sure if it's the best way to go about it, but might be useful when you choose to implement.
I'm experiencing a similar issue of "sticky" keys in RawKeyboard.instance.keysPressed
when I have a key down for shift+X but then let go of the shift before releasing x i'll have a sticky X which never disappears and hence the Shortcuts widget & co won't work at all.
Should I open a separate issue for this? Imho the sticky key problem seems very related, especially i'm not sure how this could work in a desktop environment where it's not unusual to switch apps or otherwise lose focus before receiving a matching keyup event?
This is a result of macOS engine not monitoring the flagsChanged message. We'll need to keep track of the modifier state and send additional key events when modifiers are pressed and released, similar to this example for CapsLock: https://developer.apple.com/library/archive/qa/qa1519/_index.html
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
shyndman commentedon Aug 10, 2019
cc @stuartmorgan
shyndman commentedon Aug 12, 2019
Any thoughts on approach Stuart? I had the thought that subclassing
NSApplicationmight make integration into existing projects more difficult, but that could be outweighed by the value of dealing with the raw event stream.Also, is the preference to do this work in Objective-C?
stuartmorgan-g commentedon Aug 12, 2019
No, I haven't spent any time investigating this issue. Labelling an issue isn't an indication that I've spent time investigating it.
Well, "this work" hasn't been clearly defined; the answer to that question depends on whether the work in in the framework or the template.
shyndman commentedon Aug 19, 2019
Just a quick update here. We managed to get around this with my suggestion above. I'm not sure if it's the best way to go about it, but might be useful when you choose to implement.
Before going down this path, we first tried hooking into
ExampleWindow'ssendEvent(which seems less intrusive), but the keyUp never arrives.hpoul commentedon Aug 30, 2019
I'm experiencing a similar issue of "sticky" keys in
RawKeyboard.instance.keysPressedwhen I have a key down for shift+X but then let go of the shift before releasing x i'll have a sticky X which never disappears and hence the
Shortcutswidget & co won't work at all.Should I open a separate issue for this? Imho the sticky key problem seems very related, especially i'm not sure how this could work in a desktop environment where it's not unusual to switch apps or otherwise lose focus before receiving a matching keyup event?
shyndman commentedon Sep 4, 2019
Hi @hpoul,
This narrows down some problems we've been seeing, so thanks. That said, it's different. It would make sense to file a separate issue.
gspencergoog commentedon Oct 18, 2019
/cc @franciscojma86
This is a result of macOS engine not monitoring the
flagsChangedmessage. We'll need to keep track of the modifier state and send additional key events when modifiers are pressed and released, similar to this example for CapsLock: https://developer.apple.com/library/archive/qa/qa1519/_index.htmlfranciscojma86 commentedon Oct 23, 2019
Landed, @shyndman LMK if you see any issues, thanks for filing!
github-actions commentedon Aug 13, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.