This plugin allows Flutter desktop apps to defines system/inapp wide hotkey (i.e. shortcut).

Overview

hotkey_manager

pub version

This plugin allows Flutter desktop apps to defines system/inapp wide hotkey (i.e. shortcut).

Discord


Platform Support

Linux macOS Windows
✔️ ✔️ ✔️

Quick Start

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  hotkey_manager: ^0.1.2

Or

dependencies:
  hotkey_manager:
    git:
      url: https://github.com/leanflutter/hotkey_manager.git
      ref: main

⚠️ Linux requirements

Run the following command

sudo apt-get install keybinder-3.0

Usage

import 'package:hotkey_manager/hotkey_manager.dart';

void main() {
  // Must add this line.
  WidgetsFlutterBinding.ensureInitialized();
  // For hot reload, `unregisterAll()` needs to be called.
  HotKeyManager.instance.unregisterAll();

  runApp(MyApp());
}

Register/Unregsiter a system/inapp wide hotkey.

// ⌥ + Q
HotKey _hotKey = HotKey(
  KeyCode.keyQ,
  modifiers: [KeyModifier.alt],
  // Set hotkey scope (default is HotKeyScope.system)
  scope: HotKeyScope.inapp, // Set as inapp-wide hotkey.
);
await HotKeyManager.instance.register(
  _hotKey,
  keyDownHandler: (hotKey) {
    print('onKeyDown+${hotKey.toJson()}');
  },
  // Only works on macOS.
  keyUpHandler: (hotKey){
    print('onKeyUp+${hotKey.toJson()}');
  } ,
);

await HotKeyManager.instance.unregister(_hotKey);

Use HotKeyRecorder widget to help you record a hotkey.

HotKeyRecorder(
  onHotKeyRecorded: (hotKey) {
    _hotKey = hotKey;
    setState(() {});
  },
),

Please see the example app of this plugin for a full example.

Who's using it?

  • AuthPass - Password Manager based on Flutter for all platforms. Keepass 2.x (kdbx 3.x) compatible.
  • Biyi (比译) - A convenient translation and dictionary app written in dart / Flutter.

Discussion

Welcome to join the discussion group to share your suggestions and ideas with me.

API

HotKeyManager

Method Description Linux macOS Windows
register register an system/inapp wide hotkey. ✔️ ✔️ ✔️
unregister unregister an system/inapp wide hotkey. ✔️ ✔️ ✔️
unregisterAll unregister all system/inapp wide hotkeys. ✔️ ✔️ ✔️

Related Links

License

MIT License

Copyright (c) 2021 LiJianying <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Comments
  • Build failure on Linux

    Build failure on Linux

    Hey, interested to try this out!

    For me it fails to build on a new flutter project as soon as the dependency is added:

    Details
    
    ❯ flutter run -d linux -v
    [  +43 ms] executing: uname -m
    [  +21 ms] Exit code 0 from: uname -m
    [        ] x86_64
    [   +3 ms] executing: [/home/merritt/Applications/tools/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
    [   +5 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
    [        ] 19c61fed0da681ba2068c97e22add3bde38e51e4
    [        ] executing: [/home/merritt/Applications/tools/flutter/] git tag --points-at 19c61fed0da681ba2068c97e22add3bde38e51e4
    [   +9 ms] Exit code 0 from: git tag --points-at 19c61fed0da681ba2068c97e22add3bde38e51e4
    [        ] 2.5.0-5.2.pre
    [   +6 ms] executing: [/home/merritt/Applications/tools/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
    [   +4 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
    [        ] origin/beta
    [        ] executing: [/home/merritt/Applications/tools/flutter/] git ls-remote --get-url origin
    [   +3 ms] Exit code 0 from: git ls-remote --get-url origin
    [        ] https://github.com/flutter/flutter.git
    [  +55 ms] executing: [/home/merritt/Applications/tools/flutter/] git rev-parse --abbrev-ref HEAD
    [   +4 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
    [        ] beta
    [  +47 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
    [   +2 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
    [  +49 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
    [        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'WindowsUwpEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
    [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
    [  +47 ms] Skipping pub get: version match.
    [  +14 ms] Found plugin hotkey_manager at /home/merritt/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.6/
    [  +71 ms] Found plugin hotkey_manager at /home/merritt/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.6/
    [  +14 ms] Generating /home/merritt/Downloads/flutter_hotkey_demo/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
    [  +71 ms] Initializing file store
    [   +5 ms] Skipping target: gen_localizations
    [   +2 ms] Skipping target: gen_dart_plugin_registrant
    [        ] Skipping target: _composite
    [   +1 ms] complete
    [   +3 ms] Launching lib/main.dart on Linux in debug mode...
    [   +3 ms] /home/merritt/Applications/tools/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev
    /home/merritt/Applications/tools/flutter/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot --sdk-root
    /home/merritt/Applications/tools/flutter/bin/cache/artifacts/engine/common/flutter_patched_sdk/ --incremental --target=flutter --debugger-module-names --experimental-emit-debug-metadata
    -DFLUTTER_WEB_AUTO_DETECT=true --output-dill /tmp/flutter_tools.ZEJHLO/flutter_tool.PYCTQJ/app.dill --packages /home/merritt/Downloads/flutter_hotkey_demo/.dart_tool/package_config.json
    -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-scheme org-dartlang-root --initialize-from-dill
    build/c075001b96339384a97db4862b8ab8db.cache.dill.track.dill --enable-experiment=alternative-invalidation-strategy
    [  +18 ms] Building Linux application...
    [  +14 ms] <- compile package:flutter_hotkey_demo/main.dart
    [   +1 ms] executing: [build/linux/x64/debug/] cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DFLUTTER_TARGET_PLATFORM=linux-x64 /home/merritt/Downloads/flutter_hotkey_demo/linux
    [  +35 ms] -- Checking for module 'keybinder-3.0'
    [        ] --   No package 'keybinder-3.0' found
    [        ] -- Configuring incomplete, errors occurred!
    [        ] See also "/home/merritt/Downloads/flutter_hotkey_demo/build/linux/x64/debug/CMakeFiles/CMakeOutput.log".
    [        ] CMake Error at /usr/share/cmake-3.18/Modules/FindPkgConfig.cmake:545 (message):
    [        ]   A required package was not found
    [        ] Call Stack (most recent call first):
    [        ]   /usr/share/cmake-3.18/Modules/FindPkgConfig.cmake:733 (_pkg_check_modules_internal)
    [        ]   flutter/ephemeral/.plugin_symlinks/hotkey_manager/linux/CMakeLists.txt:10 (pkg_check_modules)
    [   +8 ms] Building Linux application... (completed in 56ms)
    [+5525 ms] Exception: Unable to generate build files
    [        ] "flutter run" took 5,920ms.
    [   +3 ms] 
               #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
               #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:669:9)
               <asynchronous suspension>
               #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1125:27)
               <asynchronous suspension>
               #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #4      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
               <asynchronous suspension>
               #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:288:9)
               <asynchronous suspension>
               #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
               <asynchronous suspension>
               #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
               <asynchronous suspension>
               #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
               <asynchronous suspension>
               #10     main (package:flutter_tools/executable.dart:92:3)
               <asynchronous suspension>
               
               
    [  +81 ms] ensureAnalyticsSent: 79ms
    [   +1 ms] Running shutdown hooks
    [        ] Shutdown hooks complete
    [        ] exiting with code 1
    
    

    ❯ flutter --version Flutter 2.5.0-5.2.pre • channel beta • https://github.com/flutter/flutter.git Framework • revision 19c61fed0d (13 days ago) • 2021-08-18 17:10:31 -0700 Engine • revision 7a4c4505f6 Tools • Dart 2.14.0 (build 2.14.0-377.7.beta)

    opened by Merrit 8
  • Not able to compile on Linux

    Not able to compile on Linux

    Hi, I tried version 0.1.7 on MacOS: it works :) I tried the same code on Linux (Ubuntu), I can't compile and get the following error:

    ERROR: ../../.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.1.7/lib/src/hotkey_manager.dart:42:17: Error: The getter 'repeat' isn't defined for the class 'RawKeyDownEvent'.
    ERROR:  - 'RawKeyDownEvent' is from 'package:flutter/src/services/raw_keyboard.dart' ('../flutter/packages/flutter/lib/src/services/raw_keyboard.dart').
    ERROR: Try correcting the name to the name of an existing getter, or defining a getter or field named 'repeat'.
    ERROR:       if (value.repeat) return;
    

    For info, I installed keybinder-3.0 and libkeybinder-3.0-dev.

    [✓] Flutter (Channel stable, 2.8.1, on Ubuntu 20.04.4 LTS 5.13.0-40-generic, locale en_US.UTF-8)
        • Flutter version 2.8.1 at /home/fab/Git/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 77d935af4d (5 months ago), 2021-12-16 08:37:33 -0800
        • Engine revision 890a5fca2e
        • Dart version 2.15.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /home/fab/Android/Sdk
        • Platform android-31, build-tools 31.0.0
        • Java binary at: /snap/android-studio/119/android-studio/jre/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
        • All Android licenses accepted.
    
    [✗] 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
        • clang version 10.0.0-4ubuntu1
        • cmake version 3.16.3
        • ninja version 1.10.0
        • pkg-config version 0.29.1
    
    [✓] Android Studio (version 2021.1)
        • Android Studio at /snap/android-studio/119/android-studio
        • Flutter plugin version 67.1.1
        • Dart plugin version 211.7817
        • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    
    [✓] Connected device (1 available)
        • Linux (desktop) • linux • linux-x64 • Ubuntu 20.04.4 LTS 5.13.0-40-generic
    
    opened by hotlittlewhitedog 4
  • Overriding platform-wide shortcuts?

    Overriding platform-wide shortcuts?

    Tried the example app, and I wasn't able to register a new shortcut for already defined macOS-level shortcuts, for example Command + Q(which quits the app) or Command + Space(brings up Spotlight search).

    Is there any way to be able to override such keyboard combos? I am sure this is possible on other desktop apps, e.g. I can do it for iTerm or Android Studio through their keyboard preferences, so I am looking to also have that feature in my Flutter app.

    opened by whiplashoo 3
  • Can not response

    Can not response "Ctrl + Shift + Z" if "Ctrl + Z" has been registered first

    Please try the code sample appended. If "Ctrl + Shift + Z" is registerd after "Ctrl + Z", it it does not work

    I think this is caused by the HotKeyManager._handleRawKeyEvent method using _hotKeyList.firstWhere to match the hotkey. Maybe you need sort _hotKeyList after register a new hotkey or match modifierKey strictly in HotKeyManager._handleRawKeyEvent

    Code sample
    import 'package:flutter/material.dart';
    import 'package:hotkey_manager/hotkey_manager.dart';
    
    void main() {
      WidgetsFlutterBinding.ensureInitialized();
      hotKeyManager.unregisterAll();
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
          ),
          home: const MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      const MyHomePage({Key? key, required this.title}) : super(key: key);
    
      final String title;
    
      @override
      State<MyHomePage> createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      String lastAcceptedHotkey = '';
    
      HotKey ctrlZ = HotKey(
        KeyCode.keyZ,
        modifiers: [KeyModifier.control],
        scope: HotKeyScope.inapp,
      );
    
      HotKey ctrlShiftZ = HotKey(
        KeyCode.keyZ,
        modifiers: [KeyModifier.control, KeyModifier.shift],
        scope: HotKeyScope.inapp,
      );
    
      void _keyUpHandler(HotKey hotkey) {
        lastAcceptedHotkey = hotkey.toString();
        setState(() {});
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Column(
            children: [
              ElevatedButton(
                onPressed: () async {
                  await hotKeyManager.unregisterAll();
                  hotKeyManager.register(ctrlZ, keyUpHandler: _keyUpHandler);
                  hotKeyManager.register(ctrlShiftZ, keyUpHandler: _keyUpHandler);
                },
                child: const Text('Register order: CtrlZ, CtrlShiftZ'),
              ),
              ElevatedButton(
                onPressed: () async {
                  await hotKeyManager.unregisterAll();
                  hotKeyManager.register(ctrlShiftZ, keyUpHandler: _keyUpHandler);
                  hotKeyManager.register(ctrlZ, keyUpHandler: _keyUpHandler);
                },
                child: const Text('Register order: CtrlShiftZ, CtrlZ'),
              ),
              Text('lastAcceptedHotkey: $lastAcceptedHotkey'),
            ],
          ),
        );
      }
    }
    
    
    opened by tgalpha 1
  • 注册应用内热键(alt+s)后,触发一次后按住(alt)会一直触发

    注册应用内热键(alt+s)后,触发一次后按住(alt)会一直触发

    问题

    注册应用内热键(alt+s)后,触发一次后按住(alt)会一直触发

    环境

    [√] Flutter (Channel stable, 2.10.2, on Microsoft Windows [Version 10.0.18363.1556], locale zh-CN) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [√] Chrome - develop for the web [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.9.2) [√] Android Studio (version 2021.1) [√] IntelliJ IDEA Ultimate Edition (version 2020.3) [√] IntelliJ IDEA Ultimate Edition (version 2021.2)

    代码

    本库示例代码

    opened by MoonBlueSky 1
  • Registering a system already defined shortcut cause the old stop working

    Registering a system already defined shortcut cause the old stop working

    When you register, e.g. Command + C , that is Copy , the callback is called but the copy stops working. Any way to preserve the system predefined and the custom?

    opened by gatsbys 1
  • compilation error on Flutter 2.5.0-5.2.pre

    compilation error on Flutter 2.5.0-5.2.pre

    flutter --version
    Flutter 2.5.0-5.2.pre • channel beta • https://github.com/flutter/flutter.git
    Framework • revision 19c61fed0d (10 days ago) • 2021-08-18 17:10:31 -0700
    Engine • revision 7a4c4505f6
    Tools • Dart 2.14.0 (build 2.14.0-377.7.beta)
    

    The results of flutter run -v

    [  +14 ms]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:6:36:
    Error: Getter not found: 'none'.
    [        ]   KeyCode.none: LogicalKeyboardKey.none,
    [        ]                                    ^^^^
    [   +7 ms]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:12:37:
    Error: Getter not found: 'turbo'.
    [        ]   KeyCode.turbo: LogicalKeyboardKey.turbo,
    [        ]                                     ^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:13:51:
    Error: Getter not found: 'privacyScreenToggle'.
    [        ]   KeyCode.privacyScreenToggle: LogicalKeyboardKey.privacyScreenToggle,
    [        ]                                                   ^^^^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:16:51:
    Error: Getter not found: 'displayToggleIntExt'.
    [        ]   KeyCode.displayToggleIntExt: LogicalKeyboardKey.displayToggleIntExt,
    [        ]                                                   ^^^^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:17:43:
    Error: Getter not found: 'usbReserved'.
    [        ]   KeyCode.usbReserved: LogicalKeyboardKey.usbReserved,
    [        ]                                           ^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:18:48:
    Error: Getter not found: 'usbErrorRollOver'.
    [        ]   KeyCode.usbErrorRollOver: LogicalKeyboardKey.usbErrorRollOver,
    [        ]                                                ^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:19:43:
    Error: Getter not found: 'usbPostFail'.
    [        ]   KeyCode.usbPostFail: LogicalKeyboardKey.usbPostFail,
    [        ]                                           ^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:20:49:
    Error: Getter not found: 'usbErrorUndefined'.
    [        ]   KeyCode.usbErrorUndefined: LogicalKeyboardKey.usbErrorUndefined,
    [        ]                                                 ^^^^^^^^^^^^^^^^^
    [   +1 ms]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:159:47:
    Error: Getter not found: 'numpadBackspace'.
    [        ]   KeyCode.numpadBackspace: LogicalKeyboardKey.numpadBackspace,
    [        ]                                               ^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:160:49:
    Error: Getter not found: 'numpadMemoryStore'.
    [        ]   KeyCode.numpadMemoryStore: LogicalKeyboardKey.numpadMemoryStore,
    [        ]                                                 ^^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:161:50:
    Error: Getter not found: 'numpadMemoryRecall'.
    [        ]   KeyCode.numpadMemoryRecall: LogicalKeyboardKey.numpadMemoryRecall,
    [        ]                                                  ^^^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:162:49:
    Error: Getter not found: 'numpadMemoryClear'.
    [        ]   KeyCode.numpadMemoryClear: LogicalKeyboardKey.numpadMemoryClear,
    [        ]                                                 ^^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:163:47:
    Error: Getter not found: 'numpadMemoryAdd'.
    [        ]   KeyCode.numpadMemoryAdd: LogicalKeyboardKey.numpadMemoryAdd,
    [        ]                                               ^^^^^^^^^^^^^^^
    [   +1 ms]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:164:52:
    Error: Getter not found: 'numpadMemorySubtract'.
    [        ]   KeyCode.numpadMemorySubtract: LogicalKeyboardKey.numpadMemorySubtract,
    [        ]                                                    ^^^^^^^^^^^^^^^^^^^^
    [   +1 ms]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:165:48:
    Error: Getter not found: 'numpadSignChange'.
    [        ]   KeyCode.numpadSignChange: LogicalKeyboardKey.numpadSignChange,
    [        ]                                                ^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:166:43:
    Error: Getter not found: 'numpadClear'.
    [        ]   KeyCode.numpadClear: LogicalKeyboardKey.numpadClear,
    [        ]                                           ^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:167:48:
    Error: Getter not found: 'numpadClearEntry'.
    [        ]   KeyCode.numpadClearEntry: LogicalKeyboardKey.numpadClearEntry,
    [        ]                                                ^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:180:48:
    Error: Getter not found: 'brightnessToggle'.
    [        ]   KeyCode.brightnessToggle: LogicalKeyboardKey.brightnessToggle,
    [        ]                                                ^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:181:49:
    Error: Getter not found: 'brightnessMinimum'.
    [        ]   KeyCode.brightnessMinimum: LogicalKeyboardKey.brightnessMinimum,
    [        ]                                                 ^^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:182:49:
    Error: Getter not found: 'brightnessMaximum'.
    [        ]   KeyCode.brightnessMaximum: LogicalKeyboardKey.brightnessMaximum,
    [        ]                                                 ^^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:183:46:
    Error: Getter not found: 'brightnessAuto'.
    [        ]   KeyCode.brightnessAuto: LogicalKeyboardKey.brightnessAuto,
    [        ]                                              ^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:184:42:
    Error: Getter not found: 'kbdIllumUp'.
    [        ]   KeyCode.kbdIllumUp: LogicalKeyboardKey.kbdIllumUp,
    [        ]                                          ^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:185:44:
    Error: Getter not found: 'kbdIllumDown'.
    [        ]   KeyCode.kbdIllumDown: LogicalKeyboardKey.kbdIllumDown,
    [        ]                                            ^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:188:44:
    Error: Getter not found: 'programGuide'.
    [        ]   KeyCode.programGuide: LogicalKeyboardKey.programGuide,
    [        ]                                            ^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:203:41:
    Error: Getter not found: 'bassBoost'.
    [        ]   KeyCode.bassBoost: LogicalKeyboardKey.bassBoost,
    [        ]                                         ^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:204:43:
    Error: Getter not found: 'mediaSelect'.
    [        ]   KeyCode.mediaSelect: LogicalKeyboardKey.mediaSelect,
    [        ]                                           ^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:210:42:
    Error: Getter not found: 'launchApp2'.
    [        ]   KeyCode.launchApp2: LogicalKeyboardKey.launchApp2,
    [        ]                                          ^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:211:42:
    Error: Getter not found: 'launchApp1'.
    [        ]   KeyCode.launchApp1: LogicalKeyboardKey.launchApp1,
    [        ]                                          ^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:212:53:
    Error: Getter not found: 'launchInternetBrowser'.
    [        ]   KeyCode.launchInternetBrowser: LogicalKeyboardKey.launchInternetBrowser,
    [        ]                                                     ^^^^^^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:214:42:
    Error: Getter not found: 'lockScreen'.
    [        ]   KeyCode.lockScreen: LogicalKeyboardKey.lockScreen,
    [        ]                                          ^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:216:42:
    Error: Getter not found: 'selectTask'.
    [        ]   KeyCode.selectTask: LogicalKeyboardKey.selectTask,
    [        ]                                          ^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:217:47:
    Error: Getter not found: 'launchDocuments'.
    [        ]   KeyCode.launchDocuments: LogicalKeyboardKey.launchDocuments,
    [        ]                                               ^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:219:52:
    Error: Getter not found: 'launchKeyboardLayout'.
    [        ]   KeyCode.launchKeyboardLayout: LogicalKeyboardKey.launchKeyboardLayout,
    [        ]                                                    ^^^^^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:222:50:
    Error: Getter not found: 'launchAudioBrowser'.
    [        ]   KeyCode.launchAudioBrowser: LogicalKeyboardKey.launchAudioBrowser,
    [        ]                                                  ^^^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:241:52:
    Error: Getter not found: 'keyboardLayoutSelect'.
    [        ]   KeyCode.keyboardLayoutSelect: LogicalKeyboardKey.keyboardLayoutSelect,
    [        ]                                                    ^^^^^^^^^^^^^^^^^^^^
    [        ]
    ../../../../../Development/flutter/.pub-cache/hosted/pub.dartlang.org/hotkey_manager-0.0.3/lib/src/enums/key_code.dart:242:46:
    Error: Getter not found: 'showAllWindows'.
    [        ]   KeyCode.showAllWindows: LogicalKeyboardKey.showAllWindows,
    [        ]                                              ^^^^^^^^^^^^^^
    [+1601 ms] note: Build preparation complete
    
    opened by rburgst 1
  • Add null conditional for toJson

    Add null conditional for toJson

    If one attempts to register a system hotkey without specifying modifiers the app crashes with: "Lost connection to device." because the toJson method is returning null for modifiers.

    Reproduce issue

    Omit modifiers (crash):

    Future<void> main() async {
      WidgetsFlutterBinding.ensureInitialized();
      hotKeyManager.unregisterAll();
      final hotkey = HotKey(
        KeyCode.keyQ,
        // modifiers: [],
      );
      await hotKeyManager.register(
        hotkey,
        keyDownHandler: (hotKey) => print('key pressed'),
      );
      runApp(const MyApp());
    }
    

    Empty modifiers (no crash):

    Future<void> main() async {
      WidgetsFlutterBinding.ensureInitialized();
      hotKeyManager.unregisterAll();
      final hotkey = HotKey(
        KeyCode.keyQ,
        modifiers: [],
      );
      await hotKeyManager.register(
        hotkey,
        keyDownHandler: (hotKey) => print('key pressed'),
      );
      runApp(const MyApp());
    }
    
    opened by Merrit 0
  • [windows] Improve platform channel implementation & fix bugs

    [windows] Improve platform channel implementation & fix bugs

    Improvements made for Windows:

    • Remove additional ::GetMessage loop to avoid staying in memory.
    • Now handling hotkeys directly from RegisterTopLevelWindowProcDelegate.
    • Eliminate namespace scoped variables.
    • Use Google style for C++.
    • Other improvements like using std::unordered_map & global scope resolution for win32 calls.
    opened by alexmercerind 0
  • [Windows] keyUpHandler is not being invoked

    [Windows] keyUpHandler is not being invoked

    In example project we have 2 handlers:

     void _keyDownHandler(HotKey hotKey) {
       String log = 'keyDown ${describeEnum(hotKey.keyCode)} (${hotKey.scope})';
       BotToast.showText(text: log);
       print(log);
     }
    
     void _keyUpHandler(HotKey hotKey) {
       String log = 'keyUp   ${describeEnum(hotKey.keyCode)} (${hotKey.scope})';
       print(log);
     }
    

    keyDownHandler is being called properly, but keyUpHandler not. It can be easily observed because _keyUpHandler should print log but it doesn't do that.

    opened by jakub-stefaniak 2
  • Has no effect on only one key

    Has no effect on only one key "control"

    I want to listen the control key on keyboad with mouse left click to select multiply widget on Windows or Linux desktop platform. But it is has no effect when i listen control key.

    // register control hostkey hotKeyManager.register(HotKey(KeyCode.control), keyUpHandler: _hotkeyUpHandler);

    opened by JefferyBoy 0
  • HotKeyScope.system doesn't work on linux

    HotKeyScope.system doesn't work on linux

    final HotKey hotKey = HotKey( KeyCode.keyE, modifiers: [KeyModifier.control, KeyModifier.shift], scope: HotKeyScope.system, identifier: 'cunt', );

    doesn't work. I have keybinder-3.0 installed. I'm on the latest debian.

    opened by sgehrman 2
  • [BUG] 在 inApp 级别的快捷键回调中执行 windowManager.hide(),然后再  windowManager.show 发现 inApp 级别的快捷键都失效了。

    [BUG] 在 inApp 级别的快捷键回调中执行 windowManager.hide(),然后再 windowManager.show 发现 inApp 级别的快捷键都失效了。

    macOS

    我注册了一个 inApp 级别的快捷键,在其回调函数中执行了 windowManager.hide() 。 同时我还注册一个 system 级别的快捷键,通过回调控制 windowManager 的 hide 和 show 。

    通过 inApp 级别的快捷键,hide 软件之后再次 show ,发现其他 inApp 快捷键都失效或者不正常工作了。

    我在回调里,通过 Future.delayed 执行 hide 就不会出现这种情况。

     Future.delayed(const Duration(milliseconds: 200), () {
        windowManager.hide();
      });
    
    opened by Allenxuxu 0
  • Has a bug User macOS

    Has a bug User macOS

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

    void main() async { WidgetsFlutterBinding.ensureInitialized();

    await hotKeyManager.unregisterAll();

    runApp(const MyApp()); }

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

    @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } }

    class MyHomePage extends StatefulWidget { const MyHomePage({Key? key, required this.title}) : super(key: key);

    final String title;

    @override State createState() => _MyHomePageState(); }

    class _MyHomePageState extends State { @override void initState() { super.initState();

    registerHotkey();
    

    }

    void registerHotkey() async { HotKey hotKey = HotKey( KeyCode.keyG, modifiers: [ KeyModifier.meta, ], scope: HotKeyScope.inapp, ); await hotKeyManager.register( hotKey, keyDownHandler: (hotKey) { print('onKeyDown+${hotKey.toJson()}'); }, ); }

    @override Widget build(BuildContext context) { return Scaffold( body: Container( color: const Color(0xFFDBDDE0).withOpacity(0.21), alignment: Alignment.center, child: const TextField( decoration: InputDecoration(hintText: 'search'), ), ), ); } }

    opened by lnd1992 3
  • Migrate to new HardwareKeyboard  class

    Migrate to new HardwareKeyboard class

    hotkey_manger now use the depreacted RawKeyboard class, the new class is HardwareKeyboard page.

    And I found some bugs about RawKeyboard that official has said below:

    Compared to RawKeyboard RawKeyboard is the legacy API, and will be deprecated and removed in the future. It is recommended to always use HardwareKeyboard and KeyEvent APIs (such as FocusNode.onKeyEvent) to handle key events.

    Behavior-wise, RawKeyboard provides a less unified, less regular event model than HardwareKeyboard. For example:

    • Down events might not be matched with an up event, and vice versa (the set of pressed keys is silently updated).
    • The logical key of the down event might not be the same as that of the up event.
    • Down events and repeat events are not easily distinguishable (must be tracked manually).
    • Lock modes (such as CapsLock) only have their "enabled" state recorded. There's no way to acquire their pressing state.
    opened by shidenggui 0
Releases(v0.1.7)
Owner
LeanFlutter
To make the flutter even simpler
LeanFlutter
A Flutter package that makes it easy to customize and work with your Flutter desktop app's system tray.

system_tray A Flutter package that that enables support for system tray menu for desktop flutter apps. on Windows, macOS and Linux. Features: - Modify

AnTler 140 Dec 30, 2022
Flutter basic desktop project. Desktop todo app.

Glory Todo Desktop Basic and Primitive Flutter Desktop Project! Goal My goal is to accept my inexperience without worrying about the plugin shortcomin

Özgür 52 Dec 3, 2022
Utility Manager Flutter Application is made with Flutter and Supabase which allows user to add task, set remainder to the task, set color to separate tasks and it allows to add URL with URL's informations.

Utility Manager Flutter Application! Utility Manager Flutter Application is made with Flutter and Supabase which allows user to add task, set remainde

Kathirvel Chandrasekaran 6 Jan 6, 2022
Learn to build apps that work on Android, iOS, Web, and Desktop

Cross-Platform Development with Flutter Course Learn to build apps that work on Android, iOS, Web, and Desktop Go To Course Flutter is Google’s UI too

Mohamed Ibrahim 11 Oct 24, 2022
A Flutter plugin for handling Connectivity and REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Android, Web, Windows, Linux and macOS.

cross_connectivity A Flutter plugin for handling Connectivity and REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Androi

MarchDev Toolkit 29 Nov 15, 2022
Flutter plugin that allows users to create TextAvatar easily!

Colorize Text Avatar Colorize Text Avatar is a package to generate avatar based on your user initials. It supports to generate avatars based on your s

Deniz Çolak 17 Dec 14, 2022
Community WebView Plugin - Allows Flutter to communicate with a native WebView.

NOTICE We are working closely with the Flutter Team to integrate all the Community Plugin features in the Official WebView Plugin. We will try our bes

Flutter Community 1.4k Dec 22, 2022
Paper is a implementation of Flx Design System for Flutter

Paper is a implementation of Flx Design System for Flutter. Installing Add a lines like this to your pubspec.yaml. dependencies: paper: git:

Flx Team 3 Nov 21, 2021
An open source encrypted peer-to-peer system. Own data, own privacy. (Rust+Flutter)

An open source encrypted peer-to-peer system. Own data, own privacy. (Rust+Flutter)

Cymple Tech 124 Oct 7, 2021
E-voting system based on blockchain technology, with ethereum, flutter/dart

VOTING SYSTEM APP A voting system app made with flutter and firebase Easy-to-use electronic voting mobile application to run safe, secured and transpa

BAIMAM BOUKAR JEAN JACQUES 75 Dec 23, 2022
A Music Recommendation System made using Flutter and backed by FastAPI.

ProjectX Music A Music Recommendation System made using Flutter and backed by FastAPI. Introduction ProjectX Music is an online mobile application tha

ProjectX Music App 11 Dec 27, 2022
Plant-monitor - Plant monitoring system using IoT, MongoDB, and Flutter

Plant Monitor IoT based plant monitoring system which is connected to MongoDB. T

Souvik Biswas 15 Dec 1, 2022
Real-Distributed RTC System by pure Go and Flutter

ION ION is a distributed real-time communication system, the goal is to chat anydevice, anytime, anywhere! Online Docs https://pionion.github.io Spons

Pion 3.7k Jan 8, 2023
Automated blinds system using Raspberry PI and Flutter

Sunrise An automated blinds system using Raspberry PI controlled by an UI-friendly mobile application. This product will help the user be more comfort

Zoghlami Khalil 0 May 14, 2022
An open source encrypted peer-to-peer system. Own data, own privacy.

An open source encrypted peer-to-peer system. Own data, own privacy.

Cymple Tech 456 Jan 3, 2023
The operating system for healthcare

AfyaMoja Project prerequisites The AfyaMoja app runs on Flutter version 2.2.3 stable channel. To check the flutter version and channel installed in yo

Savannah Informatics Global Health Institute 8 Nov 20, 2022
An event management system.

?? Eventour ?? ?? The GOTO event management app. ⭐ What was our motivation? As technology advances, we often aim for newer and better approaches for s

Eshan Gupta 4 Jan 27, 2022
UIDAI Hackathon - Aadhar Address Update System

address_update_system A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you st

Aditya 1 Oct 26, 2021
Experiment for building file system.

experiment_file_system A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you s

Kato Shinya 4 Nov 15, 2021