一键导入
hotkeys
Reference for the kww-omni-hub hotkey/command system. Use when adding new features, keyboard shortcuts, or extending the command palette.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Reference for the kww-omni-hub hotkey/command system. Use when adding new features, keyboard shortcuts, or extending the command palette.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | hotkeys |
| description | Reference for the kww-omni-hub hotkey/command system. Use when adding new features, keyboard shortcuts, or extending the command palette. |
This project uses a config-driven hotkey system. All keyboard shortcuts and command palette entries are defined in a single registry.
src/config/hotkeys.ts <- Central command registry (add entries here)
src/lib/hotkeys.ts <- Shortcut matching & display formatting utils
src/components/ui/HotkeyProvider.tsx <- Context provider + useHotkeys() hook
src/components/ui/CommandPalette.tsx <- Cmd+K modal UI
src/components/ui/Tooltip.tsx <- Tooltip with shortcut badge display
src/config/hotkeys.tscommands array:{
id: 'my-new-command',
labelKey: 'commands.myNewCommand', // i18n key
shortcut: ['meta', 'shift', 'n'], // optional keyboard shortcut
action: { type: 'navigate', to: '/my-page' },
// OR: action: { type: 'function', fn: 'myFunctionName' },
group: 'navigation', // groups shown in command palette
icon: SomeLucideIcon, // optional icon
}
src/i18n/locales/en/common.json under commands.*action.type: 'function', register the handler via registerHandler('myFunctionName', () => { ... }) in the relevant component using useHotkeys().| Type | Usage |
|---|---|
navigate | Navigates to action.to via React Router |
function | Calls a registered handler by action.fn name |
import { useHotkeys } from '@/components/ui/HotkeyProvider'
function MyComponent() {
const { registerHandler } = useHotkeys()
useEffect(() => {
return registerHandler('myFunctionName', () => {
// do something
})
})
}
The registerHandler returns an unregister function for cleanup.
These are auto-registered by HotkeyProvider:
openCommandPalette — toggles the command palettetoggleSidebar — toggles sidebar collapsed stateThese are registered by their respective components:
toggleTheme — registered by ThemeToggleShortcuts are arrays of key names: ['meta', 'shift', 'k']
Modifier keys: meta, shift, alt, ctrl
meta maps to Cmd on Mac, Ctrl on Windows/LinuxWrap any interactive element to show a tooltip with shortcut:
import { Tooltip } from '@/components/ui/Tooltip'
<Tooltip label={t('commands.toggleSidebar')} shortcut={['meta', 'b']} side="right">
<button>...</button>
</Tooltip>
Commands are grouped in the palette. Add new groups by:
group string in the command entrycommands.groups.<groupName> translation keyCurrent groups: navigation, app
meta+1, meta+2, etc.meta+<letter> or meta+shift+<letter>