@splicetree/plugin-keyboard
v1.1.0
Published
提供快捷键导航能力:上下移动、展开与收起。
Readme
@splicetree/plugin-keyboard
提供快捷键导航能力:上下移动、展开与收起。
安装
pnpm add @splicetree/plugin-keyboard
使用
import { createSpliceTree } from '@splicetree/core'
import keyboardNavigation from '@splicetree/plugin-keyboard'
const tree = createSpliceTree(data, {
plugins: [keyboardNavigation],
configuration: {
keyboard: {
autoListen: true,
target: '.keyboard-wrap',
keymap: { up: 'ArrowUp', down: 'ArrowDown', left: 'ArrowLeft', right: 'ArrowRight' },
},
},
})Api
Configuration
configuration.keyboard.autoListen: boolean是否自动监听键盘(默认true)configuration.keyboard.target: HTMLElement | string | (() => HTMLElement | null)监听目标configuration.keyboard.keymap: { up?: string; down?: string; left?: string; right?: string }快捷键映射
实例方法
activeId?: string当前激活节点 id(与选择插件协同)
节点方法
- 无(键盘插件不扩展节点方法,专注输入事件)
