flutter / flutter/flutter

App throws error `Failed assertion: line 505 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'` when pressing SHIFT key using PDA keyboard

Open
#152,391 10 comments 3 reactions 0 assignees View on GitHub
a: text input e: device-specific engine P2 platform-android team-text-input triaged-text-input
Dominant language
Dart
Stars
179k
Forks
31.1k
PR merge metrics
PR metrics pending

Description

### Steps to reproduce

1. focus on textfield
2. i press key shift left on my keyboard PDA
3. error screen
4. i can't use other key later :(

I don't know

### Expected results

```
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already pressed. 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: KeyDownEvent#596ab(physicalKey: PhysicalKeyboardKey#f5c25(usbHidUsage: "0x000700e4", debugName: "Control Right"), logicalKey: LogicalKeyboardKey#d0ba2(keyId: "0x200000100", keyLabel: "Control Left", debugName: "Control Left"), character: null, timeStamp: 0:00:06.248031)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 505 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
```

### Actual results

```
════════ Exception caught by services library ══════════════════════════════════
A KeyDownEvent is dispatched, but the state shows that the physical key is already pressed. 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: KeyDownEvent#596ab(physicalKey: PhysicalKeyboardKey#f5c25(usbHidUsage: "0x000700e4", debugName: "Control Right"), logicalKey: LogicalKeyboardKey#d0ba2(keyId: "0x200000100", keyLabel: "Control Left", debugName: "Control Left"), character: null, timeStamp: 0:00:06.248031)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 505 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
```

### Code sample

Code sample

Every textfield

### Screenshots or Video

Screenshots / Video demonstration

![image](https://github.com/user-attachments/assets/d2e3513b-78ed-41cb-b069-b7144b578ca4)

### Logs

Logs

```console

### Flutter Doctor output

Doctor output

```console
Flutter (Channel stable, 3.22.2, on Ubuntu 22.04.4 LTS 6.5.0-44-generic, locale en_US.UTF-8)
• Flutter version 3.22.2 on channel stable at /home/developer/snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 761747bfc5 (7 weeks ago), 2024-06-05 22:15:13 +0200
• Engine revision edd8546116
• Dart version 3.4.3
• DevTools version 2.34.3

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /home/developer/Android/Sdk
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.

[✓] Chrome - develop for the web
• Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1

[✓] Android Studio (version 2023.3)
• Android Studio at /snap/android-studio/157
• Flutter plugin version 79.0.2
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.89.0)
• VS Code at /usr/share/code
• Flutter extension version 3.92.0

[✓] Connected device (3 available)
• HT730 (mobile) • 264247220003 • android-arm64 • Android 10 (API 29)
• Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.4 LTS 6.5.0-44-generic
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.155

[✓] Network resources
• All expected network resources are available.

! Doctor found issues in 1 category.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.