Skip to content

RawKeyboard triggers incorrect KeyUp when two keys are pressed and auto-repeating on web #58727

@erickzanardo

Description

@erickzanardo

Steps to Reproduce

  1. Run flutter create bug.
  2. Update your main with the following:
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';


void main() {
  runApp(
    MaterialApp(
      home: MyWidget(),
    ),
  );

   RawKeyboard.instance.addListener((event) {
    final isKeyDown = event is RawKeyDownEvent;
    final key = event.logicalKey.keyLabel;

    print('$isKeyDown - $key - ${event.runtimeType}');
  });
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text(
          'Build some widgets!',
          style: Theme.of(context).textTheme.headline4,
        ),
      ),
    );
  }
}
  1. flutter run -d Chrome
  2. When Chrome opens, press, and keep pressed W (or any other key), then press other key. After a while release both keys.

Expected results:

On the console:

true - w - RawKeyDownEvent
true - d - RawKeyDownEvent
false - w - RawKeyUpEvent
false - d - RawKeyUpEvent

Actual results:

TLDR: Key keeps triggering the event when pressed, and when a another is pressed, the previous key gets a RawKeyUpEvent, even if it is still pressed.

true - w - RawKeyDownEvent
true - w - RawKeyDownEvent
true - w - RawKeyDownEvent
true - d - RawKeyDownEvent
true - d - RawKeyDownEvent
true - d - RawKeyDownEvent
true - d - RawKeyDownEvent
true - d - RawKeyDownEvent
true - d - RawKeyDownEvent
true - d - RawKeyDownEvent
false - w - RawKeyUpEvent
true - d - RawKeyDownEvent
true - d - RawKeyDownEvent
true - d - RawKeyDownEvent
true - d - RawKeyDownEvent
true - d - RawKeyDownEvent
true - d - RawKeyDownEvent
false - d - RawKeyUpEvent
false - w - RawKeyUpEvent

verbose log is on attachment
verbose.log

flutter analyze
Analyzing bug...
No issues found! (ran in 6.1s)
flutter doctor -v
[✓] Flutter (Channel master, 1.19.0-2.0.pre, on Mac OS X 10.15.3 19D76, locale pt-BR)
    • Flutter version 1.19.0-2.0.pre at /Users/erick/flutter
    • Framework revision 9d58a87066 (13 days ago), 2020-05-22 22:37:01 -0700
    • Engine revision 9ce1e5c5c7
    • Dart version 2.9.0 (build 2.9.0-10.0.dev 7706afbcf5)


[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/erick/Library/Android/sdk
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/erick/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.9.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[!] VS Code (version 1.44.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • macOS      • macOS      • darwin-x64     • Mac OS X 10.15.3 19D76
    • Web Server • web-server • web-javascript • Flutter Tools
    • Chrome     • chrome     • web-javascript • Google Chrome 83.0.4103.61

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work lista: desktopRunning on desktopfound in release: 1.19Found to occur in 1.19frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions