flutter_hotkeys 1.0.0 copy "flutter_hotkeys: ^1.0.0" to clipboard
flutter_hotkeys: ^1.0.0 copied to clipboard

A global and scoped keyboard shortcut manager for Flutter apps. Simple API to register shortcuts like 'ctrl+s' globally or within specific focus scopes.

flutter_hotkeys #

A production-ready global and scoped keyboard shortcut manager for Flutter apps. Simplify your keyboard interactions with a human-readable API similar to react-hotkeys.

Works on Desktop (Windows, macOS, Linux), Web, and Mobile (External Keyboards).

Features #

  • 🌍 Global Hotkeys: Register shortcuts that work anywhere in your app.
  • 🎯 Scoped Hotkeys: Register shortcuts that only trigger when a specific widget is focused.
  • ⌨️ Human-Readable Syntax: Use strings like ctrl+s or cmd+shift+p.
  • O(1) Performance: Ultra-fast shortcut matching using a central registry.
  • 🛠️ Modifier Support: full support for ctrl, alt, shift, meta/cmd.

Installation #

Add flutter_hotkeys to your pubspec.yaml:

dependencies:
  flutter_hotkeys: ^1.0.0

Usage #

Global Hotkeys #

Register a shortcut anywhere in your app:

import 'package:flutter_hotkeys/flutter_hotkeys.dart';

// Register
Hotkeys.register('ctrl+s', () {
  print('Save triggered!');
});

// Unregister
Hotkeys.unregister('ctrl+s');

Scoped Hotkeys #

Use HotkeyScope to define shortcuts that only work when a specific part of the UI is focused (e.g., an editor).

HotkeyScope(
  shortcuts: {
    'ctrl+b': () => makeBold(),
    'ctrl+i': () => makeItalic(),
  },
  child: TextField(
    decoration: InputDecoration(labelText: 'Focused Editor'),
  ),
)

Syntax Reference #

Supported Modifiers:

  • ctrl / control
  • alt / option
  • shift
  • meta / cmd / command / win

Examples:

  • ctrl+s
  • ctrl+shift+p
  • alt+enter
  • cmd+k
  • f1
  • enter, escape, backspace, del

Comparison with Flutter Shortcuts API #

Feature flutter_hotkeys Flutter Shortcuts / Actions
Simplicity Extremely Simple (Static API) Complex (Intent/Action/Shortcut boilerplate)
Global Scope Native Support Difficult to implement globally
Syntax String-based (ctrl+s) Class-based (SingleActivator)
Focus required Optional Required for standard shortcuts

License #

This project is licensed under the MIT License - see the LICENSE file for details.

1
likes
0
points
183
downloads

Publisher

unverified uploader

Weekly Downloads

A global and scoped keyboard shortcut manager for Flutter apps. Simple API to register shortcuts like 'ctrl+s' globally or within specific focus scopes.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flutter_hotkeys