KeyMapData 类
KeyMapData
类用于封装键盘按键的映射数据,定义在 lib/domain/services/key_maps.dart
文件中。
构造函数
const KeyMapData({
required this.label,
this.shortLabel,
this.glyph,
this.symbol,
this.icon,
});
参数说明
参数 | 类型 | 描述 |
---|---|---|
label | String | 按键的完整标签文本,如 "control" |
shortLabel | String? | 按键的短标签文本,如 "ctrl" |
glyph | String? | 按键的符号表示,如 "⌃" |
symbol | String? | 按键的辅助符号,如 "~" 对应 "`" 键 |
icon | String? | 按键图标的路径 |
示例
// 定义 Control 键的映射
const KeyMapData(
label: "control",
shortLabel: "ctrl",
glyph: "⌃",
icon: KeyIcons.control,
)
平台差异
部分按键在不同平台上有不同的表示:
meta: switchPlatform<KeyMapData>(
windows: const KeyMapData(
label: "win",
symbol: "\u{229E}",
icon: KeyIcons.meta,
),
macos: const KeyMapData(
label: "command",
shortLabel: "cmd",
symbol: "⌘",
icon: KeyIcons.macMeta,
),
linux: const KeyMapData(
label: "Meta",
symbol: "✦",
icon: KeyIcons.meta,
),
)
### 7.3 提交与 PR
```bash
# 提交更改
git add README.md
git commit -m "docs: update KeyMapData API documentation"
# 推送到远程
git push origin feature/update-keymap-docs
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考