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

keymap 封面
套件詳情v0.0.92

keymap

一個可重用的鍵盤捷徑小部件,具備彈性且簡潔的使用者介面與焦點處理。

AndroidiOSmacOSWindowsLinux
近 30 天下載
1080
喜歡數
34
Pub 分數
140

安裝套件

flutter pub add keymap

套件介紹

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

Keymap 是一個 Flutter 套件,提供可重複使用的 widget,用於實現鍵盤捷徑,具備最小化且彈性的 UI。它支援焦點管理,並可在 Android、iOS、macOS、Windows 和 Linux 等多個平台運作。此套件讓開發者能輕鬆定義鍵盤組合,並對使用者輸入做出回應,無需撰寫冗長的程式碼。適用於需要高效鍵盤導航或熱鍵的應用程式,透過直覺的捷徑處理提升可存取性與使用者體驗。

適用情境

  • 在桌面應用程式中實現鍵盤快捷鍵
  • 提升生產力工具的可存取性
  • 為遊戲控制創建快捷鍵
  • 建構響應式網頁和桌面介面
  • 在表單中啟用快速導航

主要特色

  • 靈活且簡潔的使用者介面設計
  • 內建焦點處理
  • 跨平台支援
  • 可重複使用的捷徑定義
  • 用於鍵組合映射的簡單 API

適合對象

  • 桌面應用程式開發者
  • 以可存取性為重點的專案
  • 生產力工具創作者
  • Web 與多平台 Flutter 應用
  • 需要鍵盤導航的 UI

使用建議

  • 複雜組件中需要手動管理焦點
  • 可能需要額外的樣式來實現自定義外觀
  • 有限的內建視覺反饋
  • 未針對僅行動裝置使用情境進行優化
  • 依賴於平台特定的鍵盤事件處理

原始 README

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

Keymap

A keymap widget letting a developer easily allow end users to use keyboard shortcuts and an associated help screen overlay to any app.

This is pre-alpha and the API will probably change in the future.

Getting started

pub package

dependencies:
  keymap: <latest-version>

Features

  • Easily add keyboard shortcuts to any widget tree
  • Clear, readable help screen
  • Allows rich text introductions with images using the Markdown format
  • Handles focus, passing up unhandled key events
  • Respects application theme colors and fonts

Usage

Add a KeyMap widget to your tree in the build method

@override
Widget build(BuildContext context) {
  return KeyboardWidget(
    bindings: [
      KeyAction.fromString('A','increment the counter', () {
        setState(() {
          count++;
        });}, isControlPressed: true),
      KeyAction(LogicalKeyboardKey.keyD, 'decrement the counter', () {
        setState(() {
          count--;
        });
      }, isAltPressed: true, isControlPressed: true),
    ],
    child: Column(
      children: [
        const Text('Up arrow for adding, down arrow to subtract'),
        Text('count: $count'),
      ],
    ),
  );
}

You can optionally set the number of columns for the text shown in the help screen

  @override
  Widget build(BuildContext context) {
    return KeyboardWidget(
      columnCount: 2,
      child: Scaffold(

This creates keyboard shortcuts that call the referenced methods and a help screen that can be called up by pressing F1 (or any key you choose):

It will shift colors to match your app's theme (here in dark mode)

You can add rich text (using Markdown format) above the keyboard map. A code sample showing how to do this can be found in the examples directory

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案