搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目