Skip to content

[Linux] PhysicalKeyboardKey events with AltGr + ? keys are wrong order #154053

@fufesou

Description

@fufesou

I'm trying to get the USB HID codes for key events. But the order is wrong.

Steps to reproduce

  1. Run the example code on Linux.
  2. Switch to FR input method.
  3. Press AltGr + E. Press AltGr, press E, release E, release AltGr.

Expected results

For PhysicalKeyboardKey:

  1. AltGr/Alt Right key down event.
  2. E key down event.
  3. E key up event.
  4. AltGr/Alt Right key up event.

Actual results

  1. AltGr/Alt Right key down event.
  2. AltGr/Alt Right key up event.
  3. E key down event. Character .
  4. E key up event.

Code sample

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Keyboard Event Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const KeyboardEventPage(),
    );
  }
}

class KeyboardEventPage extends StatefulWidget {
  const KeyboardEventPage({super.key});

  @override
  _KeyboardEventPageState createState() => _KeyboardEventPageState();
}

class _KeyboardEventPageState extends State<KeyboardEventPage> {
  final List<String> _lastKeyEvents = [];
  final FocusNode _focusNode = FocusNode();

  @override
  Widget build(BuildContext context) {
    final child = Scaffold(
      appBar: AppBar(
        title: const Text('Keyboard Event Demo'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Press any key:',
              style: TextStyle(fontSize: 20),
            ),
            const SizedBox(height: 20),
            for (final keyEvent in _lastKeyEvents)
              Text(
                keyEvent,
                style: const TextStyle(fontSize: 16),
              ),
          ],
        ),
      ),
    );
    return FocusScope(
      autofocus: true,
      child: Focus(
        autofocus: true,
        canRequestFocus: true,
        focusNode: _focusNode,
        onKeyEvent: (node, event) {
          setState(() {
            _lastKeyEvents.add(event.toString());
            if (_lastKeyEvents.length > 10) {
              _lastKeyEvents.removeAt(0);
            }
          });
          return KeyEventResult.handled;
        },
        child: child,
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.24.1, on Ubuntu 22.04.4 LTS 6.5.0-44-generic,
    locale en_US.UTF-8)
    • Flutter version 3.24.1 on channel stable at
      /home/username/workspace/flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5874a72aa4 (4 days ago), 2024-08-20 16:46:00 -0500
    • Engine revision c9b9d5780d
    • Dart version 3.5.1
    • DevTools version 2.37.2

[✗] 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/to/linux-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 (Cannot find Chrome executable at
    google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1.1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

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

[!] Proxy Configuration
    • HTTP_PROXY is set
    ! NO_PROXY is not set

[✓] Connected device (1 available)
    • Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.4 LTS 6.5.0-44-generic

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

! Doctor found issues in 4 categories.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)found in release: 3.24Found to occur in 3.24found in release: 3.25Found to occur in 3.25frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-linuxBuilding on or for Linux specificallyr: fixedIssue is closed as already fixed in a newer versionteam-linuxOwned by the Linux platform teamtriaged-linuxTriaged by the Linux platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions