Open prasmussen opened 2 years ago
Hi @prasmussen, Thanks for filing the issue. I am able to reproduce the issue on stable and the master channel on the web, When cmd+k
is pressed and then released (both keys) and when the left arrow
is pressed and released the console outputs: keys: Arrow Left + Key K)
instead of (keys: Arrow Left)
This issue is only on the web and works fine on Desktop.
cc: @dkwingsmt
This looks like a framework issue. Removing the web label for now.
I can reproduce it on windows desktop but not on macOS desktop, this indeed seems to be from the framework
flutter: LogicalKeySet#00104(keys: Alt Left)
flutter: LogicalKeySet#720bd(keys: Alt Left + Key K)
flutter: LogicalKeySet#e3f7b(keys: Arrow Left + Key K)
flutter: LogicalKeySet#c8814(keys: Arrow Right + Key K)
flutter: LogicalKeySet#113e1(keys: Arrow Down + Key K)
flutter: LogicalKeySet#6b3a8(keys: Arrow Up + Key K)
flutter: LogicalKeySet#113e1(keys: Arrow Down + Key K)
flutter: LogicalKeySet#e3f7b(keys: Arrow Left + Key K)
flutter: LogicalKeySet#113e1(keys: Arrow Down + Key K)
flutter: LogicalKeySet#6b3a8(keys: Arrow Up + Key K)
flutter: LogicalKeySet#caf5e(keys: Key B + Key K + Key V)
flutter: LogicalKeySet#61f76(keys: Key J + Key K)
The triaged-desktop
label is irrelevant if there is no team-desktop
label or fyi-desktop
label.
HardwareKeyboard.instance.logicalKeysPressed
returns keys that was previously pressed instead of only the currently pressed key. Happens when pressing the meta key in addition to other keys, on Mac OS.Steps to Reproduce
cmd + k
and releasearrow left
and releasek
when only thearrow left
key was pressedExpected results:
Actual results:
Code sample
```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( home: GlobalKeyboardListener( onKeyEvent: (KeyEvent event) { if (event is KeyDownEvent) { if (HardwareKeyboard.instance.logicalKeysPressed.isNotEmpty) { final pressedKeys = LogicalKeySet.fromSet( HardwareKeyboard.instance.logicalKeysPressed, ); // ignore: avoid_print print(pressedKeys); } } return false; }, child: const Text("hello"), ), ); } } class GlobalKeyboardListener extends StatefulWidget { final bool Function(KeyEvent keyEvent) onKeyEvent; final Widget child; const GlobalKeyboardListener({ required this.onKeyEvent, required this.child, Key? key, }) : super(key: key); @override StateLogs
``` Analyzing foo... No issues found! (ran in 1.3s) ``` ``` $ flutter doctor -v [✓] Flutter (Channel stable, 2.8.0, on macOS 12.0.1 21A559 darwin-x64, locale en-GB) • Flutter version 2.8.0 at /usr/local/Caskroom/flutter/2.2.1/flutter • Upstream repository git@github.com:flutter/flutter.git • Framework revision cf44000065 (13 days ago), 2021-12-08 14:06:50 -0800 • Engine revision 40a99c5951 • Dart version 2.15.0 [✗] Android toolchain - develop for Android devices ✗ Unable to locate Android SDK. Install Android Studio from: https://developer.android.com/studio/index.html On first launch it will assist you in installing the Android SDK components. (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions). If the Android SDK has been installed to a custom location, please use `flutter config --android-sdk` to update to that location. [!] Xcode - develop for iOS and macOS (Xcode 13.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer ✗ CocoaPods not installed. CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/platform-plugins To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions. [✓] 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.63.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.29.0 [✓] Connected device (1 available) • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110 ! Doctor found issues in 3 categories. ```