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

源码仓库

使用此插件的项目