Repository: flutter
Issue: [web on macOS] "A KeyUpEvent is dispatched, but the state shows that the physical key is pressed on a different logical key" after using Cmd+digit then Option+digit
Labels: a: text input,engine,platform-mac,platform-web,has reproducible steps,P2,found in release: 2.10,found in release: 2.13,team-web,triaged-web

Seeing this on latest `master` today. There are a few other open issues with this exception, although it's not clear if they're the same problem (this is web on macOS). Below is a simple app that just prints when 1, ctrl+1, shift+1, option+1, cmd+1 are pressed. The following actions trigger the exception when running in Chrome:

- Load the app
- Press `1` and ensure `1` is printed to the dev console (if not, try pressing `<tab>` and then try again)
- Press cmd+1 (`cmd+1` should be printed)
- Press option+1

It doesn't happen if you don't press `cmd+1` before `option+1`, or if you wait a while (eg. > 1sec) after pressing `cmd+1` before pressing `option+1`.

```
Error: Assertion failed:
_pressedKeys[event.physicalKey] == event.logicalKey
"A KeyUpEvent is dispatched, but the state shows that the physical key is pressed on a different logical key. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyUpEvent#89cf7(physicalKey: PhysicalKeyboardKey#7001e(usbHidUsage: \"0x0007001e\", debugName: \"Digit 1\"), logicalKey: LogicalKeyboardKey#000a1(keyId: \"0x000000a1\", keyLabel: \"¡\", debugName: \"Key ¡\"), character: null, timeStamp: 0:00:33.117899, synthesized) and the recorded logical key LogicalKeyboardKey#00031(keyId: \"0x00000031\", keyLabel: \"1\", debugName: \"Digit 1\")"
    at Object.throw_ [as throw] (http://localhost:49559/dart_sdk.js:5069:11)
    at Object.assertFailed (http://localhost:49559/dart_sdk.js:4994:15)
at http://localhost:49559/packages/flutter/src/services/restoration.dart.lib.js:5399:98
at hardware_keyboard.HardwareKeyboard.new.[_assertEventIsRegular] (http://localhost:49559/packages/flutter/src/services/restoration.dart.lib.js:5404:26)
at hardware_keyboard.HardwareKeyboard.new.handleKeyEvent (http://localhost:49559/packages/flutter/src/services/restoration.dart.lib.js:5458:34)
at hardware_keyboard.KeyEventManager.new.handleKeyData (http://localhost:49559/packages/flutter/src/services/restoration.dart.lib.js:5609:38)
    at http://localhost:49559/dart_sdk.js:171308:47
    at Object.invoke (http://localhost:49559/dart_sdk.js:190680:7)
    at _engine.EnginePlatformDispatcher.__.invokeOnKeyData (http://localhost:49559/dart_sdk.js:171308:17)
    at _engine.KeyboardBinding.__.[_onKeyData] (http://localhost:49559/dart_sdk.js:169995:49)
    at http://localhost:49559/dart_sdk.js:170361:21
    at _engine.KeyboardConverter.new.[_handleEvent] (http://localhost:49559/dart_sdk.js:170288:51)
    at _engine.KeyboardConverter.new.handleEvent (http://localhost:49559/dart_sdk.js:170364:27)
    at http://localhost:49559/dart_sdk.js:170001:76
    at loggedHandler (http://localhost:49559/dart_sdk.js:169978:18)
```

```
[✓] Flutter (Channel master, 2.13.0-0.0.pre.166, on macOS 12.3 21E230 darwin-arm, locale en-GB)
    • Flutter version 2.13.0-0.0.pre.166 at /Users/danny/Dev/Google/flutter
    • Upstream repository git@github.com:DanTup/flutter.git
    • Framework revision 6af40a7004 (22 hours ago), 2022-03-19 19:15:23 -0400
    • Engine revision 900e3c0917
    • Dart version 2.17.0 (build 2.17.0-222.0.dev)
    • DevTools version 2.11.4

[✗] Android toolchain - develop for Android devices
    ✗ ANDROID_HOME = /Users/danny/Library/Android/sdk
      but Android SDK not found at this location.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] VS Code (version 1.65.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.37.20220301

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.3 21E230 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 99.0.4844.74

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 2 categories.
```

```dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Shortcuts(
        shortcuts: const {
          SingleActivator(LogicalKeyboardKey.digit1): MyIntent('1'),
          SingleActivator(LogicalKeyboardKey.digit1, control: true):
              MyIntent('ctrl+1'),
          SingleActivator(LogicalKeyboardKey.digit1, alt: true):
              MyIntent('alt+1'),
          SingleActivator(LogicalKeyboardKey.digit1, meta: true):
              MyIntent('meta+1'),
          SingleActivator(LogicalKeyboardKey.digit1, shift: true):
              MyIntent('shift+1'),
        },
        child: Actions(
          actions: {
            MyIntent: CallbackAction<MyIntent>(
                onInvoke: (intent) => print(intent.keys)),
          },
          child: const Focus(
            autofocus: true,
            child: Center(
              child: Text('Press 1, ctrl+1, alt+1, meta+1, shift+1'),
            ),
          ),
        ),
      ),
    );
  }
}

class MyIntent extends Intent {
  final String keys;

  const MyIntent(this.keys);
}
```