搜尋套件、儲存庫與 APP 分類

套件詳情v0.3.0

hotkey_manager

此外掛允許 Flutter 桌面應用程式定義系統/應用內全域熱鍵(即捷徑)。

macOSWindowsLinux
近 30 天下載
6.8萬
喜歡數
147
Pub 分數
140

安裝套件

flutter pub add hotkey_manager

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

hotkey_manager 套件讓 Flutter 桌面應用程式能在 macOS、Windows 與 Linux 上註冊並回應系統級或應用內的鍵盤捷徑。它允許開發者定義自訂快捷鍵,無論目前活躍的應用程式為何,都能觸發特定動作,進而提升使用者的生產力與可及性。此外,該套件與 Flutter 的事件處理機制無縫整合,提供簡單的 API 來管理如 Ctrl+Shift+S 或 Cmd+T 之類的按鍵組合。非常適合需要快速存取功能卻不需瀏覽選單的應用。

適用情境

  • 為應用操作創建全域快捷方式
  • 快速存取常用功能
  • 透過鍵盤導航改善可存取性
  • 使用快捷鍵支援建構生產力工具
  • 與現有桌面工作流程整合

主要特色

  • 支援跨平台的系統級捷徑鍵
  • 用於定義鍵組合的簡單 API
  • 跨平台相容性(macOS、Windows、Linux)
  • 與 Flutter 應用的非侵入式整合
  • 處理衝突和重複註冊

適合對象

  • 面向多個操作系統的桌面應用程式開發者
  • 生產力和實用軟體
  • 需要高級鍵盤互動的應用程式
  • 開發可存取的桌面體驗的開發者

使用建議

  • 在某些系統上需要平台特定的權限
  • 可能與現有系統捷徑衝突
  • 僅限桌面平台
  • 需要適當的清理以避免記憶體洩漏
  • 不適用於行動或Web應用程式

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

🚀 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

所屬分類

依賴

依賴清單 4 項

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

原始碼儲存庫

使用此套件的專案