hotkey_manager

Last updated:

0 purchases

hotkey_manager Image
hotkey_manager Images
Add to Cart

Description:

hotkey manager

hotkey_manager #

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

English | 简体中文




hotkey_manager

Platform Support
Quick Start

Installation

Linux requirements


Usage


Who's using it?
API

HotKeyManager


Related Links
License




Platform Support #



Linux
macOS
Windows




✔️
✔️
✔️



Quick Start #
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
hotkey_manager: ^0.2.3
copied to clipboard
Or
dependencies:
hotkey_manager:
git:
path: packages/hotkey_manager
url: https://github.com/leanflutter/hotkey_manager.git
ref: main
copied to clipboard
Linux requirements

keybinder-3.0

Run the following command
sudo apt-get install keybinder-3.0
copied to clipboard
Usage #
import 'package:hotkey_manager/hotkey_manager.dart';

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

runApp(MyApp());
}
copied to clipboard
Register/Unregsiter a system/inapp wide hotkey.
// ⌥ + Q
HotKey _hotKey = HotKey(
key: PhysicalKeyboardKey.keyQ,
modifiers: [HotKeyModifier.alt],
// Set hotkey scope (default is HotKeyScope.system)
scope: HotKeyScope.inapp, // Set as inapp-wide hotkey.
);
await hotKeyManager.register(
_hotKey,
keyDownHandler: (hotKey) {
print('onKeyDown+${hotKey.toJson()}');
},
// Only works on macOS.
keyUpHandler: (hotKey){
print('onKeyUp+${hotKey.toJson()}');
} ,
);

await hotKeyManager.unregister(_hotKey);

await hotKeyManager.unregisterAll();
copied to clipboard
Use HotKeyRecorder widget to help you record a hotkey.
HotKeyRecorder(
onHotKeyRecorded: (hotKey) {
_hotKey = hotKey;
setState(() {});
},
),
copied to clipboard

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

Who's using it? #

Airclap - Send any file to any device. cross platform, ultra fast and easy to use.
AuthPass - Password Manager based on Flutter for all platforms. Keepass 2.x (kdbx 3.x) compatible.
Biyi (比译) - A convenient translation and dictionary app.

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 #

https://github.com/soffes/HotKey
https://github.com/kupferlauncher/keybinder

License #
MIT

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.