This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
shell/platform/darwin/macos/framework/Source Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -47,18 +47,20 @@ - (void)handleEvent:(NSEvent*)event callback:(FlutterAsyncKeyCallback)callback {
47
47
case NSEventTypeKeyUp:
48
48
type = @" keyup" ;
49
49
break ;
50
- case NSEventTypeFlagsChanged:
51
- if (event.modifierFlags < _previouslyPressedFlags) {
50
+ case NSEventTypeFlagsChanged: {
51
+ // Remove the 0x100 bit set by Cocoa when no modifiers are pressed.
52
+ NSEventModifierFlags modifierFlags = event.modifierFlags & ~0x100 ;
53
+ if (modifierFlags < _previouslyPressedFlags) {
52
54
type = @" keyup" ;
53
- } else if (event.modifierFlags > _previouslyPressedFlags &&
54
- event.modifierFlags > 0x100 ) { // 0x100 is empty modifierFlags
55
+ } else if (modifierFlags > _previouslyPressedFlags) {
55
56
type = @" keydown" ;
56
57
} else {
57
58
// ignore duplicate modifiers; This can happen in situations like switching
58
59
// between application windows when MacOS only sends the up event to new window.
59
60
return ;
60
61
}
61
62
break ;
63
+ }
62
64
default :
63
65
NSAssert (false , @" Unexpected key event type (got %lu )." , event.type);
64
66
}
You can’t perform that action at this time.
0 commit comments