diff --git a/lib/web_ui/lib/src/engine/key_map.g.dart b/lib/web_ui/lib/src/engine/key_map.g.dart index d02946a8b6726..d4cecae4e6bc0 100644 --- a/lib/web_ui/lib/src/engine/key_map.g.dart +++ b/lib/web_ui/lib/src/engine/key_map.g.dart @@ -574,6 +574,7 @@ const Map> kWebLogicalLocationMap = >{ '8': [0x00000000038, null, null, 0x00200000238], // digit8, null, null, numpad8 '9': [0x00000000039, null, null, 0x00200000239], // digit9, null, null, numpad9 'Alt': [0x00200000104, 0x00200000104, 0x00200000105, null], // altLeft, altLeft, altRight, null + 'AltGraph': [0x00100000103, null, 0x00100000103, null], // altGraph, null, altGraph, null 'ArrowDown': [0x00100000301, null, null, 0x00200000232], // arrowDown, null, null, numpad2 'ArrowLeft': [0x00100000302, null, null, 0x00200000234], // arrowLeft, null, null, numpad4 'ArrowRight': [0x00100000303, null, null, 0x00200000236], // arrowRight, null, null, numpad6 diff --git a/lib/web_ui/lib/src/engine/keyboard_binding.dart b/lib/web_ui/lib/src/engine/keyboard_binding.dart index bb451771adc0c..b5403ac3eedee 100644 --- a/lib/web_ui/lib/src/engine/keyboard_binding.dart +++ b/lib/web_ui/lib/src/engine/keyboard_binding.dart @@ -584,7 +584,6 @@ class KeyboardConverter { _kPhysicalAltLeft, _kPhysicalAltRight, _kLogicalAltLeft, - _kLogicalAltRight, altPressed ? ui.KeyEventType.down : ui.KeyEventType.up, eventTimestamp, ); @@ -592,7 +591,6 @@ class KeyboardConverter { _kPhysicalControlLeft, _kPhysicalControlRight, _kLogicalControlLeft, - _kLogicalControlRight, controlPressed ? ui.KeyEventType.down : ui.KeyEventType.up, eventTimestamp, ); @@ -600,7 +598,6 @@ class KeyboardConverter { _kPhysicalMetaLeft, _kPhysicalMetaRight, _kLogicalMetaLeft, - _kLogicalMetaRight, metaPressed ? ui.KeyEventType.down : ui.KeyEventType.up, eventTimestamp, ); @@ -608,7 +605,6 @@ class KeyboardConverter { _kPhysicalShiftLeft, _kPhysicalShiftRight, _kLogicalShiftLeft, - _kLogicalShiftRight, shiftPressed ? ui.KeyEventType.down : ui.KeyEventType.up, eventTimestamp, ); @@ -618,7 +614,6 @@ class KeyboardConverter { int physicalLeft, int physicalRight, int logicalLeft, - int logicalRight, ui.KeyEventType type, num domTimestamp, ) { @@ -635,12 +630,14 @@ class KeyboardConverter { // Synthesize an up event for left key if pressed if (synthesizeUp && leftPressed) { - _synthesizeKeyUpEvent(domTimestamp, physicalLeft, logicalLeft); + final int knownLogicalKey = _pressingRecords[physicalLeft]!; + _synthesizeKeyUpEvent(domTimestamp, physicalLeft, knownLogicalKey); } // Synthesize an up event for right key if pressed if (synthesizeUp && rightPressed) { - _synthesizeKeyUpEvent(domTimestamp, physicalRight, logicalRight); + final int knownLogicalKey = _pressingRecords[physicalRight]!; + _synthesizeKeyUpEvent(domTimestamp, physicalRight, knownLogicalKey); } } diff --git a/lib/web_ui/test/engine/pointer_binding_test.dart b/lib/web_ui/test/engine/pointer_binding_test.dart index 1d3317316a4ab..fd4cca8cab730 100644 --- a/lib/web_ui/test/engine/pointer_binding_test.dart +++ b/lib/web_ui/test/engine/pointer_binding_test.dart @@ -760,6 +760,41 @@ void testMain() { }, ); + _testEach<_BasicEventContext>( + <_BasicEventContext>[ + _PointerEventContext(), + _MouseEventContext(), + _TouchEventContext(), + ], + 'should synthesize modifier keys up event for AltGraph', + (_BasicEventContext context) { + PointerBinding.instance!.debugOverrideDetector(context); + + final List keyDataList = []; + final KeyboardConverter keyboardConverter = createKeyboardConverter(keyDataList); + PointerBinding.instance!.debugOverrideKeyboardConverter(keyboardConverter); + + final int physicalAltRight = kWebToPhysicalKey['AltRight']!; + final int logicalAltGraph = kWebLogicalLocationMap['AltGraph']![0]!; + + // Simulate pressing `AltGr` key. + keyboardConverter.handleEvent(keyDownEvent('AltRight', 'AltGraph')); + expect(keyboardConverter.debugKeyIsPressed(physicalAltRight), true); + keyDataList.clear(); // Remove key data generated by handleEvent. + + glassPane.dispatchEvent(context.primaryDown()); + expect(keyDataList.length, 1); + expectKeyData(keyDataList.last, + type: ui.KeyEventType.up, + physical: physicalAltRight, + logical: logicalAltGraph, + character: null, + synthesized: true, + ); + expect(keyboardConverter.debugKeyIsPressed(physicalAltRight), false); + }, + ); + _testEach<_ButtonedEventMixin>( <_ButtonedEventMixin>[ if (!isIosSafari) _PointerEventContext(),