Repository navigation
[Web] RawKeyboardListener does not return correct data #35347
Copy link
Copy link
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: contributor-productivityTeam-specific productivity, code health, technical debt.Team-specific productivity, code health, technical debt.c: tech-debtTechnical debt, code quality, testing, etc.Technical debt, code quality, testing, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.platform-webWeb applications specificallyWeb applications specificallyteam-webOwned by Web platform teamOwned by Web platform teamteam: skip-testAn issue used to track tests that are skipped.An issue used to track tests that are skipped.triaged-webTriaged by Web platform teamTriaged by Web platform team
Description
Steps to Reproduce
Gist of code to reproduce the problem:
https://gist.github.com/mjeffw/8f3f57d23b596fde3c1a8dac93a64549
- Create a flutter web app with a TextField wrapped by a RawKeyboardListener
- In the onKey callback, check for a specific key using the following code:
if (value.logicalKey == LogicalKeyboardKey.keyA) print('A'); - Run the web app and type the expected key. It never matches.
If I print the logicalKey value of the RawKeyEvent, and type the letter 'A', here is the output:
dart_sdk.js:18740 LogicalKeyboardKey#00039(keyId: "0x00000039", keyLabel: "9", debugName: "Digit 9")
dart_sdk.js:18740 LogicalKeyboardKey#f1dc1(keyId: "0x1000c018a", keyLabel: null, debugName: "Launch Mail")
dart_sdk.js:18740 LogicalKeyboardKey#f1dc1(keyId: "0x1000c018a", keyLabel: null, debugName: "Launch Mail")
dart_sdk.js:18740 LogicalKeyboardKey#00039(keyId: "0x00000039", keyLabel: "9", debugName: "Digit 9")
Logs
Jeffs-MacBook-Pro-2:flutter_web_rawkeyboardlistener_example jeff$ webdev serve --verbose
[INFO] Connecting to the build daemon...
[INFO] Generating build script...
[INFO] Generating build script completed, took 401ms
[INFO]
[INFO] Starting daemon...
[INFO]BuildDefinition: Initializing inputs
[INFO]BuildDefinition: Reading cached asset graph...
[WARNING]BuildDefinition: Throwing away cached asset graph due to Dart SDK update.
[INFO]BuildDefinition: Cleaning up outputs from previous builds....
[INFO]BuildDefinition: Cleaning up outputs from previous builds. completed, took 136ms
[INFO] Generating build script...
[INFO] Generating build script completed, took 109ms
[INFO]
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 12.4s
[INFO]
[INFO] Starting daemon...
[INFO]BuildDefinition: Initializing inputs
[INFO]BuildDefinition: Building new asset graph...
[INFO]BuildDefinition: Building new asset graph completed, took 1.5s
[INFO]BuildDefinition: Checking for unexpected pre-existing outputs....
[INFO]BuildDefinition: Checking for unexpected pre-existing outputs. completed, took 2ms
[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 1.5s
[INFO]
[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 2ms
[INFO]
[INFO] Setting up file watchers...
[INFO] Setting up file watchers completed, took 4ms
[INFO]
[INFO] Registering build targets...
[INFO] Starting initial build...
[INFO] Starting resource servers...
[INFO] Serving `web` on http://127.0.0.1:8080
[INFO] About to build [web]...
[INFO]Build: Running build...
[INFO]Heartbeat: 1.0s elapsed, 89/108 actions completed.
[INFO]Heartbeat: 2.0s elapsed, 285/303 actions completed.
[INFO]Heartbeat: 3.1s elapsed, 517/537 actions completed.
[INFO]Heartbeat: 4.2s elapsed, 694/726 actions completed.
[INFO]Heartbeat: 5.3s elapsed, 694/726 actions completed.
[INFO]Heartbeat: 6.4s elapsed, 705/741 actions completed.
[INFO]Heartbeat: 7.4s elapsed, 716/750 actions completed.
[INFO]Heartbeat: 8.5s elapsed, 720/752 actions completed.
[INFO]Heartbeat: 9.5s elapsed, 722/752 actions completed.
[INFO]Heartbeat: 10.6s elapsed, 726/754 actions completed.
[INFO]Heartbeat: 11.6s elapsed, 731/754 actions completed.
[INFO]Heartbeat: 12.7s elapsed, 734/754 actions completed.
[INFO]Heartbeat: 13.8s elapsed, 737/754 actions completed.
[INFO]Heartbeat: 14.8s elapsed, 739/754 actions completed.
[INFO]Heartbeat: 15.8s elapsed, 740/754 actions completed.
[INFO]Heartbeat: 16.9s elapsed, 740/754 actions completed.
[INFO]Heartbeat: 17.9s elapsed, 742/754 actions completed.
[INFO]Heartbeat: 18.9s elapsed, 743/754 actions completed.
[INFO]Heartbeat: 20.0s elapsed, 744/754 actions completed.
[INFO]Heartbeat: 21.0s elapsed, 745/754 actions completed.
[INFO]Heartbeat: 22.1s elapsed, 748/754 actions completed.
[INFO]Heartbeat: 23.1s elapsed, 750/754 actions completed.
[INFO]Heartbeat: 24.2s elapsed, 750/754 actions completed.
[INFO]Heartbeat: 25.3s elapsed, 752/754 actions completed.
[INFO]Heartbeat: 26.3s elapsed, 752/754 actions completed.
[INFO]Heartbeat: 27.4s elapsed, 752/754 actions completed.
[INFO]Heartbeat: 28.4s elapsed, 752/754 actions completed.
[INFO]Heartbeat: 29.5s elapsed, 752/754 actions completed.
[INFO]Heartbeat: 30.5s elapsed, 754/754 actions completed.
[INFO]Build: Running build completed, took 30.9s
[INFO]Build: Caching finalized dependency graph...
[INFO]Build: Caching finalized dependency graph completed, took 197ms
[INFO]Build: Succeeded after 31.1s with 560 outputs (3266 actions)
[INFO] ----------------------------------------------------------------------------------------------------------------------------------------------------------------
[INFO] About to build [web]...
[INFO]Build: Updating asset graph...
[INFO]Build: Updating asset graph completed, took 12ms
[INFO]Build: Running build...
[INFO]Build: Running build completed, took 359ms
[INFO]Build: Caching finalized dependency graph...
[INFO]Build: Caching finalized dependency graph completed, took 242ms
[INFO]Build: Succeeded after 652ms with 9 outputs (7 actions)
[INFO] ----------------------------------------------------------------------------------------------------------------------------------------------------------------
flutter analyze
Analyzing flutter_web_rawkeyboardlistener_example...
No issues found! (ran in 2.8s)
Jeffs-MacBook-Pro-2:flutter_web_rawkeyboardlistener_example jeff$ flutter doctor -v
[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.5 18F132, locale en-US)
• Flutter version 1.5.4-hotfix.2 at /Users/jeff/Projects/git/flutter
• Framework revision 7a4c33425d (9 weeks ago), 2019-04-29 11:05:24 -0700
• Engine revision 52c7a1e849
• Dart version 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/jeff/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.2.1, Build version 10E1001
• ios-deploy 1.9.4
• CocoaPods version 1.6.1
[✓] Android Studio (version 3.4)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 35.3.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[✓] IntelliJ IDEA Community Edition (version 2018.3.5)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin version 33.4.2
• Dart plugin version 183.5912.23
[✓] VS Code (version 1.35.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.2.0
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: contributor-productivityTeam-specific productivity, code health, technical debt.Team-specific productivity, code health, technical debt.c: tech-debtTechnical debt, code quality, testing, etc.Technical debt, code quality, testing, etc.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.platform-webWeb applications specificallyWeb applications specificallyteam-webOwned by Web platform teamOwned by Web platform teamteam: skip-testAn issue used to track tests that are skipped.An issue used to track tests that are skipped.triaged-webTriaged by Web platform teamTriaged by Web platform team
Activity
a-marenkov commentedon Jul 11, 2019
@mjeffw try this workaround
deckerst commentedon Nov 13, 2019
This code used to work with v1.10.15, but since v1.10.16 the
RawKeyboardListenerdoes not receive the key events when theTextFieldis focused.In my case, I need to handle the up/down arrow keys. Is there a workaround?
phamnhuvu-dev commentedon Apr 19, 2020
same issue with @deckerst
Skquark commentedon Jun 8, 2020
Was struggling with this bug too, it doesn't seem to fire RawKeyboardListener on web build. I've been futzing with it to use keyboard to control ScrollBar - ScrollView to bandaid bug here: #43694 but after our efforts, got stuck with this. Even tried the if (keyEvent.data is RawKeyEventDataWeb) part and researched the other issues regarding. Most of the bug reports were already closed like #33857 and #52656 but still should bump the issue.
TahaTesser commentedon Jun 16, 2020
@mjeffw
Pressing
aandtabCode Sample
flutter doctor -v
10 remaining items
markusaksli-nc commentedon Aug 5, 2020
Hi @Piinks
Since the original issue is no longer reproducible on the latest master and the skip audit has been merged can this be closed?
Thank you
Piinks commentedon Aug 6, 2020
It looks like there are still 8 tests being skipped because of this issue, if they can be un-skipped and pass then this is resolved. It does not appear that it is though since they are still being skipped:
https://github.com/flutter/flutter/blob/master/packages/flutter/test/services/raw_keyboard_test.dart
https://github.com/flutter/flutter/blob/master/packages/flutter/test/widgets/focus_traversal_test.dart
The skipped tests have a comment referencing this issue number so you can search for them. :)
test: Skip focus traversal navigation in nested lists tests on browse…