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

套件詳情v0.1.4

keyboard_shortcuts

允許您在應用程式中使用捷徑的組件。您可以自行定義自訂捷徑,以及全域性捷徑(例如自動捲動至底部和頂部)。

近 30 天下載
52
喜歡數
47
Pub 分數
40

安裝套件

flutter pub add keyboard_shortcuts

套件介紹

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

一個 Flutter 套件,讓開發者能在其應用程式中實作自訂與全域鍵盤快速鍵。它允許使用者使用鍵組合觸發動作,例如自動捲動至螢幕頂端或底端。此套件設計為易於整合,提供簡單的元件來定義和管理快速鍵。支援本地與全域快速鍵處理,非常適合注重生產力的應用程式。開發者可透過定義自己的快速鍵邏輯來擴展功能。此套件為開源,並在 GitHub 上維護。

適用情境

  • 實現導航捷徑
  • 啟用快速捲動操作
  • 新增自定義使用者定義的捷徑
  • 透過鍵盤導航改善可存取性
  • 建立高效的開發工具

主要特色

  • 支援自定快捷方式定義
  • 處理全域與區域捷徑
  • 與現有組件的輕鬆整合
  • 開源且持續維護
  • 提供清晰的捷徑管理 API

適合對象

  • 生產力應用
  • 開發者工具
  • 可存取性增強
  • 內容密集型介面
  • 需要快速導航的應用

使用建議

  • 可能與系統級捷徑衝突
  • 需要小心處理焦點與上下文
  • 不適用於所有UI模式
  • 有限的平台特定自訂
  • 需要在不同輸入方式下進行測試

原始 README

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

Flutter Keyboard Shortcuts

Keyboard shortcuts to add where you want

Example

On controlLeft + key P are pressed, user navigate to SecondPage() helpLabel will be display on help menu

    KeyBoardShortcuts(
        keysToPress: {LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.keyP},
        onKeysPressed: () => Navigator.push(
          context,
          MaterialPageRoute(builder: (context) => SecondPage()),
        ),
        helpLabel: "Go to Second Page",
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                'You have pushed the button this many times:',
              ),
              Text(
                '$_counter',
                style: Theme.of(context).textTheme.headline4,
              ),
            ],
          ),
        ),
      ),

If globalShortcuts is set to true, user can use Home Button to go on Homepage, up and down button to go on top or bottom of the page and escape to go on last page

    KeyBoardShortcuts(
        globalShortcuts: true,
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                'You have pushed the button this many times:',
              ),
              Text(
                '$_counter',
                style: Theme.of(context).textTheme.headline4,
              ),
            ],
          ),
        ),
      ),

initShortCuts() is used to customize shortcuts, you can set home page, title of help menu, icon on custom shortcuts and custom help menu

    initShortCuts(HomePage(), helpTitle : "Help Menu", helpIcon : Icons.menu);

You can also use initShortCuts to create your own global shortcuts, they will be allow in all page were globalShortcuts is true without rewriting these shortcuts

  initShortCuts(
    HomePage(),
    keysToPress: {
      {LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.keyP},
    },
    onKeysPressed: {() => print("Work")},
    helpLabel: {"Print Work"},
  );

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案