Raw web keyCode cannot be extracted from KeyEvent
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Description
We have migrated our keyboard handling from Flutter 3.16 to 3.19 according to [this migration guide](https://docs.flutter.dev/release/breaking-changes/key-event-migration#migrating-your-code-that-uses-rawkeyevent). After the migration we can't get the keyCode from the KeyEvent as we did before.
We're using Flutter for a webos application and for that we need to get the keyCode from the `RawKeyEventDataWeb` to distinguish between the special keys coming from the [LG magic remote](https://webostv.developer.lge.com/develop/guides/magic-remote).
### Expected results
KeyCode like 413 for stop
### Actual results
We're getting the `usbHidUsage`: `0x01700000000` and the `LogicalKeyboardKey` `unidentified`
### Code sample
Code sample
```dart
Focus(
onKeyEvent: (FocusNode node, KeyEvent event) {
if (event is RawKeyDownEvent && event.data is RawKeyEventDataWeb) {
final keyCode = (event.data as RawKeyEventDataWeb).keyCode;
// Do something with the key code
}
return KeyEventResult.ignored;
},
child: ...
```
### Flutter Doctor output
Doctor output
```console
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale de-DE)
• Flutter version 3.19.6 on channel stable at ...
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 54e66469a9 (5 days ago), 2024-04-17 13:08:03 -0700
• Engine revision c4cd48e186
• Dart version 3.3.4
• DevTools version 2.31.1
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at ...
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A240d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
[✓] Android Studio (version 2023.1)
• Android Studio at /Applications/Android Studio2.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
[✓] VS Code (version 1.88.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.62
[✓] Network resources
• All expected network resources are available.
• No issues found!
```
Contributor guide
Assessment
This issue has not been assessed yet.