cosmos-in-code / galactic_hotkeys

"Galactic Hotkeys" is a robust Flutter library for streamlined keyboard shortcuts in your apps. Inspired by the cosmos, it associates actions with key combos, enhancing user experience. Customize and optimize interactions effortlessly. Explore efficient control in your Flutter projects with this intuitive, space-themed tool.
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Same key triggered after some time (Android Chromebook) #1

Open hotlittlewhitedog opened 5 months ago

hotlittlewhitedog commented 5 months ago

Hi all,

I tried your hotkey manager in an Android Chromebook emulator, it works some minutes and after without reason or errors, it doesn't work anymore. A last key pressed in my configuration (example KeyB) is triggered all the time even I push any key, even keys not registered in the config as KeyQ.

Rem: Maybe I have to put your widget on top of the Scaffold, please let me know. Rem2: I'm always in the same instance of the desktop app. Rem3: the app works perfectly without a key manager.

Thanks for any help :)

bool _canPop() => Navigator.of(homePageContext).canPop();

...
final Widget body = Container(
      child: ListView(
        controller: chapterTextScrollController,
        padding: EdgeInsets.only(left: 15.0, top: 0.0, right: 15.0, bottom: 0.0),
        shrinkWrap: false,
        physics: const AlwaysScrollableScrollPhysics(),
        children: [
          Container(
            padding: EdgeInsets.zero,
            child: Column(
              children: [
                scrollTab,
                chapterTitle,
                GestureDetector(
                  onHorizontalDragEnd: (details) => _onHorizontalDragEnd(details),
                  child: ChapterWidget(bbNames: gbbNames, chapterType: chapterType, lstChapterObject: chapterObject, colCount: gcolCount),
                ),
              ],
            ),
          ),
        ],
      ),
    );
return Scaffold(
      key: scaffoldKey,
      drawer: drawer,
      appBar: appBar,
      body: GHK.GalacticHotkeys<ShortcutKeys>(
        shortcuts: {
          ShortcutKeys.ESC:   [[LogicalKeyboardKey.escape]],
          ShortcutKeys.LEFT:  [[LogicalKeyboardKey.arrowLeft]],
          ShortcutKeys.RIGHT: [[LogicalKeyboardKey.arrowRight]],
          ShortcutKeys.M:     [[LogicalKeyboardKey.keyM]],
          ShortcutKeys.TAB:   [[LogicalKeyboardKey.tab]],
          ShortcutKeys.S:     [[LogicalKeyboardKey.keyS]],
          ShortcutKeys.F:     [[LogicalKeyboardKey.keyF]],
          ShortcutKeys.B:     [[LogicalKeyboardKey.keyB]],
          ShortcutKeys.A:     [[LogicalKeyboardKey.keyA]],
          ShortcutKeys.P:     [[LogicalKeyboardKey.keyP]],
        },
        onShortcutPressed: (ShortcutKeys identifier, List<LogicalKeyboardKey> pressedKeys)
        {
          print("Shortcut pressed: ${identifier.toString()}");

          switch (identifier) {
            case ShortcutKeys.ESC: {
              //Never block the ESC key
              if (_canPop()) Navigator.of(homePageContext).pop();
              break;
            }
            case ShortcutKeys.LEFT: {
              if (_canPop()) return; //Block the key
              _onClickBtnChapterLeft();
              break;
            }
            case ShortcutKeys.RIGHT: {
              if (_canPop()) return; //Block the key
              _onClickBtnChapterRight();
              break;
            }
            case ShortcutKeys.M: {
              if (_canPop()) return; //Block the key
              if (scaffoldKey.currentState != null && scaffoldKey.currentState!.hasDrawer) scaffoldKey.currentState?.openDrawer();
              break;
            }
            case ShortcutKeys.TAB: {
              if (_canPop()) return; //Block the key
              _onShowHistMenu(homePageContext, mnuHistoryValue);
              break;
            }
            case ShortcutKeys.S: {
              if (_canPop()) return; //Block the key
              _onShowSearchMenu(homePageContext, mnuSearchValue);
              break;
            }
            case ShortcutKeys.F: {
              if (_canPop()) return; //Block the key
              //TODO: search F
              _onShowSearchMenu(homePageContext, mnuSearchValue);
              break;
            }
            case ShortcutKeys.B: {
              if (_canPop()) return; //Block the key
              _onShowBooksMenu(homePageContext);
              break;
            }
            case ShortcutKeys.P: {
              if (_canPop()) return; //Block the key
              _onShowPrblsMenu(homePageContext, mnuPrblsValue);
              break;
            }
            case ShortcutKeys.A: {
              if (_canPop()) return; //Block the key
              _onShowArtsMenu(homePageContext, mnuArtsValue);
              break;
            }
            default:
              break;
          }
        },
        child: body,
      ),
    );

`[✓] Flutter (Channel stable, 3.19.6, on macOS 14.2.1 23C71 darwin-x64, locale en-BE) • Flutter version 3.19.6 on channel stable at /Users/xxx/AndroidStudioProjects/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 54e66469a9 (4 weeks ago), 2024-04-17 13:08:03 -0700 • Engine revision c4cd48e186 • Dart version 3.3.4 • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/xxx/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = /Users/xxx/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15E204a • CocoaPods version 1.15.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3) • 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 17.0.10+0-17.0.10b1087.21-11572160)

[✓] Connected device (2 available) • macOS (desktop) • macos • darwin-x64 • macOS 14.2.1 23C71 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.201 `

juarezfranco commented 2 months ago

Did you try Maybe I have to put your widget on top of the Scaffold, please let me know.?