hotkey_system 0.0.2 copy "hotkey_system: ^0.0.2" to clipboard
hotkey_system: ^0.0.2 copied to clipboard

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

HotkeySystem

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


English | Turkish


Platform Support #

macOS
✔️

Quick Start #

Installation #

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

dependencies:
  hotkey_system: ^0.0.2

Or

dependencies:
  hotkey_system:
    git:
      url: https://github.com/suysoftware/hotkey_system.git
      ref: main

Usage #

import 'package:hotkey_system/hotkey_system.dart';

void main() async {
  // Must add this line.
  WidgetsFlutterBinding.ensureInitialized();
  // For hot reload, `unregisterAll()` needs to be called.
  await hotKeySystem.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 hotKeySystem.register(
  _hotKey,
  keyDownHandler: (hotKey) {
    print('onKeyDown+${hotKey.toJson()}');
  },
  // Only works on macOS.
  keyUpHandler: (hotKey){
    print('onKeyUp+${hotKey.toJson()}');
  } ,
);

await hotKeySystem.unregister(_hotKey);

await hotKeySystem.unregisterAll();

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? #

  • ThinkBuddy - Made for native MacOS experience integrated with AI

API #

HotKeySystem #

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

License #

MIT

14
likes
0
points
34
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)
View/report issues

Topics

#hotkey #shortcuts #keyboard #macos-shortcuts #hardware-keyboard

License

unknown (license)

Dependencies

collection, flutter, uuid

More

Packages that depend on hotkey_system