Skip to content

Shift-Digit Shortcuts are broken on macOS #90167

Closed

Description

Shift Keyboard Key not detected

A while ago, almost all keyboard shortcuts in our app stopped working. Now, I investigated it and realized that shift is completely broken.

That is, any shortcuts that use shift do not work. That applies both to SingleActivator as well as LogicalKeySet; LogicalKeyboardKey.shift simply seems to be broken. This happens to our users on Chrome using any device (Windows laptop, Macbook, w/e).


SingleActivator(
  LogicalKeyboardKey.keyA,
)

Is detected but:

SingleActivator(
  LogicalKeyboardKey.keyA,
  shift: true,
)

is not detected. All the other modifiers still work.

Steps to Reproduce

  1. Run flutter create bug --platforms=web.
  2. Update main.dart as follows:
Click to expand code snippet
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Shift is broken',
      shortcuts: const {
        SingleActivator(
          LogicalKeyboardKey.keyA,
          control: true,
        ): PrintIntent(false),
        SingleActivator(
          LogicalKeyboardKey.keyA,
          shift: true,
        ): PrintIntent(true),
      },
      actions: {
        PrintIntent: CallbackAction<PrintIntent>(onInvoke: (intent) {
          if (intent.shift) {
            // This is never called.
            print('Shift is working');
            return;
          }
          print('Control is working.');
        }),
      },
      builder: (context, child) {
        return const Focus(
          autofocus: true,
          child: Placeholder(),
        );
      },
    );
  }
}

class PrintIntent extends Intent {
  const PrintIntent(this.shift);

  final bool shift;
}
  1. Run cd bug and flutter run -d chrome.
  2. Focus the window.
  3. Press CTRL + A.
  4. Press SHIFT + A.

Expected results: Control is working. and then Shift is working.

Actual results: Control is working. only.

Logs
Performing hot restart...
Waiting for connection from debug service on Chrome...
Restarted application in 374ms.
Control is working.
Control is working.
Control is working.
[✓] Flutter (Channel dev, 2.6.0-5.1.pre, on Microsoft Windows [Version 10.0.19042.1165], locale en-150)
    • Flutter version 2.6.0-5.1.pre
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f2903d3da5 (7 days ago), 2021-09-08 12:44:29 -0700
    • Engine revision 0bd9be379a
    • Dart version 2.15.0 (build 2.15.0-82.0.dev)


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

[✓] Connected device (3 available)
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 93.0.4577.82

Activity

  1. maheshj01 commented on Sep 16, 2021

    @maheshj01
    Member

    Hi @creativecreatorormaybenot, Thanks for filing the issue. I am able to replicate the issue on the latest stable 2.5.0 as well as the latest master 2.6.0-6.0.pre.114. Shift shortcuts work perfectly fine on the older version (stable 2.2.3) this can be verified with the below code sample.

    It seems like this is a regression probably introduced in #80756

    For the code sample below which looks for keybindings ctrl+N or shift+N

    The keybinding shift+N works if N is pressed first followed by shift. But this doesn't work for the above example which uses SingleActivator

    code sample
    import 'package:flutter/material.dart';
    import 'package:flutter/services.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          theme: ThemeData.dark().copyWith(
            scaffoldBackgroundColor: Colors.blue,
          ),
          debugShowCheckedModeBanner: false,
          home: Scaffold(
            body: Center(
              child: HomeworkPane(name: 'Homework'),
            ),
          ),
        );
      }
    }
    
    class NewHomeworkIntent extends Intent {
      const NewHomeworkIntent({required this.name});
    
      final String name;
    }
    
    class HomeworkPane extends StatefulWidget {
      const HomeworkPane({Key? key, required this.name}) : super(key: key);
    
      final String name;
    
      @override
      _HomeworkPaneState createState() => _HomeworkPaneState();
    }
    
    class _HomeworkPaneState extends State<HomeworkPane> {
      final List<String> _homework = <String>[];
    
      void _createNewHomework(String name) {
        print('Creating new homework $name');
        setState(() {
          _homework.add(name);
        });
      }
    
      @override
      Widget build(BuildContext context) {
        return Shortcuts(
          shortcuts: <LogicalKeySet, Intent>{
            LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyN):
                NewHomeworkIntent(name: '${widget.name} ${_homework.length + 1}'),
            LogicalKeySet(LogicalKeyboardKey.shift, LogicalKeyboardKey.keyN):
                NewHomeworkIntent(name: '${widget.name} ${_homework.length + 1}'),
          },
          child: Actions(
            actions: <Type, Action<Intent>>{
              NewHomeworkIntent: CallbackAction<NewHomeworkIntent>(
                  onInvoke: (NewHomeworkIntent intent) =>
                      _createNewHomework(intent.name)),
            },
            child: Focus(
              autofocus: true,
              child: Column(
                children: <Widget>[
                  const Text('List of Homework'),
                  ..._homework.map<Widget>((String name) => Text(name)).toList(),
                ],
              ),
            ),
          ),
        );
      }
    }
    
    flutter doctor -v
    [✓] Flutter (Channel master, 2.6.0-6.0.pre.114, on macOS 11.5.2 20G95 darwin-arm, locale en-GB)
        • Flutter version 2.6.0-6.0.pre.114 at /Users/mahesh/Documents/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision cd1892f04f (4 hours ago), 2021-09-15 22:17:02 -0700
        • Engine revision 5a09f16031
        • Dart version 2.15.0 (build 2.15.0-110.0.dev)
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 12.5.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • CocoaPods version 1.10.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 60.1.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.59.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.26.0
    
    [✓] Connected device (3 available)
        • iPhone 12 Pro Max (mobile) • 5430F628-A903-402C-A635-D55D7E6EEFCA • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)            • macos                                • darwin-arm64   • macOS 11.5.2 20G95 darwin-arm
        • Chrome (web)               • chrome                               • web-javascript • Google Chrome 93.0.4577.82
    
    • No issues found!
    
    [✓] Flutter (Channel stable, 2.5.0, on macOS 11.5.2 20G95 darwin-arm, locale en-GB)
        • Flutter version 2.5.0 at /Users/mahesh/Documents/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 4cc385b4b8 (8 days ago), 2021-09-07 23:01:49 -0700
        • Engine revision f0826da7ef
        • Dart version 2.14.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.5.1, Build version 12E507
        • CocoaPods version 1.10.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 60.1.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.59.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.26.0
    
    [✓] Connected device (3 available)
        • iPhone 12 Pro Max (mobile) • 5430F628-A903-402C-A635-D55D7E6EEFCA • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)            • macos                                • darwin-arm64   • macOS 11.5.2 20G95 darwin-arm
        • Chrome (web)               • chrome                               • web-javascript • Google Chrome 93.0.4577.82
    
    • No issues found!
    [✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.2 20G95 darwin-arm, locale en-GB)
        • Flutter version 2.2.3 at /Users/mahesh/Documents/flutter_dev
        • Framework revision f4abaa0735 (3 months ago), 2021-07-01 12:46:11 -0700
        • Engine revision 241c87ad80
        • Dart version 2.13.4
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-31, build-tools 31.0.0
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.5.1, Build version 12E507
        • CocoaPods version 1.10.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 60.1.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.59.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.26.0
    
    [✓] Connected device (3 available)
        • iPhone 12 Pro Max (mobile) • 5430F628-A903-402C-A635-D55D7E6EEFCA • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)            • macos                                • darwin-arm64   • macOS 11.5.2 20G95 darwin-arm
        • Chrome (web)               • chrome                               • web-javascript • Google Chrome 93.0.4577.82
    
    • No issues found!
    
  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: regressionIt was better in the past than it is now
    a: text inputEntering text in a text field or keyboard related problems
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Sep 16, 2021
  3. creativecreatorormaybenot commented on Sep 16, 2021

    @creativecreatorormaybenot
    ContributorAuthor

    Thanks - this seems like a very serious issue to me.

    @maheshmnj I also realized now: the behavior seems to be different on Macbook and Windows - on Windows, shift does not work at all and on Macbook, the alt modifier (option key) does not work at all either.

    I also have no workaround for this, i.e. I am not sure how to make our shortcuts work at all right now (I thought I could use another modifier, but that is not the case). I cannot use the control modifier because there are too many actions bound to that already.

  4. creativecreatorormaybenot commented on Sep 16, 2021

    @creativecreatorormaybenot
    ContributorAuthor

    @maheshmnj should I create a separate issue for the "Option (or Alt) ⌥" key?

  5. HansMuller commented on Sep 16, 2021

    @HansMuller
    Contributor
  6. LongCatIsLooong commented on Sep 16, 2021

    @LongCatIsLooong
    Contributor

    @dkwingsmt it looks like when Shift is pressed the logical key reported for A is 0x00000041 and we're expecting 0x00000061 (flutter run -d linux):

    flutter: event: RawKeyUpEvent#e4f4e(logicalKey: LogicalKeyboardKey#00041(keyId: "0x00000041", keyLabel: "A", debugName: "Key A"), physicalKey: PhysicalKeyboardKey#70004(usbHidUsage: "0x00070004", debugName: "Key A")), candidatesByKey: null, candidatesByNull: null
    flutter: {LogicalKeyboardKey#00061(keyId: "0x00000061", keyLabel: "A", debugName: "Key A"): [_ActivatorIntentPair#cec76(activator: Control + Key A, intent: PrintIntent#891c9), _ActivatorIntentPair#f9136(activator: Shift + Key A, intent: PrintIntent#3908e)]}
    
  7. justinmc commented on Sep 16, 2021

    @justinmc
    Contributor

    I took a quick look at tracking down the PR that caused this, but to me it looks like it was something before both #78522 and #80756. I was able to reproduce the bug on the commit before eb73516 from #78522.

    Also just to note, the built-in shortcuts related to shift in DefaultTextEditingShortcuts still work fine for whatever reason.

  8. maheshj01 commented on Sep 17, 2021

    @maheshj01
    Member

    @maheshmnj should I create a separate issue for the "Option (or Alt) ⌥" key?

    Yes, if the issue is reproducible. Please file that as a separate issue.

  9. 23 remaining items

  10. flutter-triage-bot commented on Aug 17, 2023

    @flutter-triage-bot

    This issue was assigned to @dkwingsmt but has had no status updates in a long time. To remove any ambiguity about whether the issue is being worked on, the assignee was removed.

  11. removed
    ⏳Bot is counting down the days until it unassigns the issue
    on Aug 17, 2023
  12. dkwingsmt commented on Aug 24, 2023

    @dkwingsmt
    Contributor

    The Web part should have been fixed with flutter-team-archive/engine#34625, Nov 2022. This issue should have been fixed. If anyone has encountered this issue lately, feel free to reply or open a new issue with flutter doctor --verbose.

  13. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 24, 2023
  14. github-actions commented on Sep 14, 2023

    @github-actions

    Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
    If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
    Thanks for your contribution.

  15. github-actions commented on Sep 28, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  16. locked as resolved and limited conversation to collaborators on Sep 28, 2023
  17. added
    team-macosOwned by the macOS platform team
    and removed on Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowfound in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-macosOwned by the macOS platform teamwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions