Search packages, repositories and app categories

Package detailsv0.3.0

hotkey_manager

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

macOSWindowsLinux
30-day downloads
68.2K
Likes
147
Pub points
140

Install package

flutter pub add hotkey_manager

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The hotkey_manager package enables Flutter desktop applications to register and respond to system-wide or in-app keyboard shortcuts on macOS, Windows, and Linux. It allows developers to define custom hotkeys that trigger specific actions regardless of the active application, enhancing user productivity and accessibility. The plugin integrates seamlessly with Flutter's event handling, providing a simple API for managing key combinations like Ctrl+Shift+S or Cmd+T. Ideal for apps requiring quick access to features without navigating menus.

Use cases

  • Creating global shortcuts for app actions
  • Enabling rapid access to frequently used functions
  • Improving accessibility through keyboard navigation
  • Building productivity tools with shortcut support
  • Integrating with existing desktop workflows

Key features

  • Supports system-wide hotkeys across platforms
  • Simple API for defining key combinations
  • Cross-platform compatibility (macOS, Windows, Linux)
  • Non-intrusive integration with Flutter apps
  • Handles conflicts and duplicate registrations

Suitable for

  • Desktop app developers targeting multiple operating systems
  • Productivity and utility software
  • Apps requiring advanced keyboard interaction
  • Developers building accessible desktop experiences

Considerations

  • Requires platform-specific permissions on some systems
  • May conflict with existing system shortcuts
  • Limited to desktop platforms only
  • Needs proper cleanup to avoid memory leaks
  • Not suitable for mobile or web applications

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

🚀 Ship Your App Faster: Try Fastforge - The simplest way to build, package and distribute your Flutter apps.

hotkey_manager

pub version

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


English | 简体中文


Platform Support

Linux macOS Windows
✔️ ✔️ ✔️

Quick Start

Installation

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

dependencies:
  hotkey_manager: ^0.2.3

Or

dependencies:
  hotkey_manager:
    git:
      path: packages/hotkey_manager
      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() async {
  // Must add this line.
  WidgetsFlutterBinding.ensureInitialized();
  // For hot reload, `unregisterAll()` needs to be called.
  await hotKeyManager.unregisterAll();

  runApp(MyApp());
}

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();

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?

  • 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

Categories

Dependencies

Dependency list 4 items

  • hotkey_manager_platform_interface^0.2.0
  • nativeapi^0.5.6
  • uni_platform^0.1.3
  • uuid>=3.0.7 <5.0.0

Source repository

Projects using this package