Skip to content

[Windows] HardwareKeyboard misses next key press after alt is pressed #177822

@josh-audio

Description

@josh-audio

Steps to reproduce

These steps use Windows 11 with Flutter 3.35.7 (see doctor output below).

  1. Create a new Flutter project with flutter create
  2. In main.dart, add the following in main() after runApp():
    HardwareKeyboard.instance.addHandler((event) {
      if (event is KeyDownEvent) {
        print('Key pressed: ${event.logicalKey.debugName}');
      }
      return false;
    });
  3. Run the project
  4. Try the following two things:
    1. Press the left alt key 4 times
    2. Press alt, then release alt, then press another key

Expected results

I expect an output like the following:

(for the first)
Key pressed: Alt Left
Key pressed: Alt Left
Key pressed: Alt Left
Key pressed: Alt Left

(for the second)
Key pressed: Alt Left
Key pressed: Key A

Actual results

Instead, I get the following output:

(for the first)
Key pressed: Alt Left
Key pressed: Alt Left

(for the second)
Key pressed: Alt Left

Note that this does not happen for other keys, including other modifiers like shift and control.

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());

  HardwareKeyboard.instance.addHandler((event) {
    if (event is KeyDownEvent) {
      print('Key pressed: ${event.logicalKey.debugName}');
    }
    return false;
  });
}

// Rest of file unchanged from flutter create output

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.35.7, on Microsoft Windows [Version 10.0.26200.6899], locale en-US) [411ms]
    • Flutter version 3.35.7 on channel stable at C:\Users\qbgee\Documents\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision adc9010625 (9 days ago), 2025-10-21 14:16:03 -0400
    • Engine revision 035316565a
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop,
      enable-android, enable-ios, cli-animations, enable-lldb-debugging

[✓] Windows Version (11 Home 64-bit, 25H2, 2009) [1,943ms]

[✗] Android toolchain - develop for Android devices [161ms]
    ✗ 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/to/windows-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.


[✓] Chrome - develop for the web [118ms]
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.10) [116ms]
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.14.36327.8
    • Windows 10 SDK version 10.0.26100.0

[!] Android Studio (not installed) [12ms]
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/windows-android-setup for detailed instructions).

[✓] VS Code (version 1.105.1) [11ms]
    • VS Code at C:\Users\qbgee\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.120.0

[✓] Connected device (3 available) [194ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26200.6899]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 141.0.7390.123
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 141.0.3537.99

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

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopengineflutter/engine related. See also e: labels.platform-windowsBuilding on or for Windows specificallyr: fixedIssue is closed as already fixed in a newer versionteam-windowsOwned by the Windows platform teamtriaged-windowsTriaged by the Windows platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions