Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[macOS] Inconsitent keyboard modifier state after unfocusing window with modifier key present #135349

Closed
flutter/engine
#46230
@knopp

Description

@knopp

Sample code:

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

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Listener(
          behavior: HitTestBehavior.opaque,
          onPointerDown: (e) {
            print('RAW: ${RawKeyboard.instance.keysPressed}');
            print('HW: ${HardwareKeyboard.instance.logicalKeysPressed}');
          },
          child: Container(),
        ),
      ),
    );
  }
}

To reproduce, focus the flutter window, hold shift key and click on another window to unfocus flutter window. After that, depress the shift key and click anywhere in the Flutter window.

Expected output (keys currently pressed):

flutter: RAW: {}
flutter: HW: {}

Actual output (raw keyboard has shift key stuck):

flutter: RAW: {LogicalKeyboardKey#df100(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left")}
flutter: HW: {}

HW keyboard does not have the shift key pressed anymore, but when you shift+click now, the HW keyboard will not register the shift until keyboard event.

The problem here is, as far as I can tell, that only FlutterKeyboardManager only synchronizes modifiers for FlutterEmbedderKeyResponder, not doing anything for FlutterChannelKeyResponder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsengineflutter/engine repository. See also e: labels.found in release: 3.13Found to occur in 3.13found in release: 3.15Found to occur in 3.15has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-macBuilding on or for macOS specificallyr: fixedIssue is closed as already fixed in a newer versionteam-macosOwned by the macOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions