hotkey
lobehub/lobehub
Add or edit LobeHub keyboard shortcuts with proper registration and i18n support.
What is hotkey?
This skill enables you to create and manage keyboard shortcuts in LobeHub by defining hotkey constants, registering default key combinations, adding translations, and hooking them into UI components. Use it when you need to add new keyboard shortcuts or modify existing ones across the application.
- Define new hotkeys in HotkeyEnum with unique identifiers
- Register default key combinations using combineKeys and scope configuration
- Add internationalized titles and descriptions for hotkeys
- Create and register hooks that bind hotkeys to actions using useHotkeyById
- Add hotkey tooltips to UI buttons and components
- Handle platform-specific key combinations (Cmd/Ctrl) with Key.Mod
How to install hotkey
npx skills add https://github.com/lobehub/lobehub --skill hotkey- Access to LobeHub source code repository
- Familiarity with TypeScript and React hooks
- Understanding of LobeHub's file structure (src/types, src/const, src/locales, src/hooks)
How to use hotkey
- 1.Update HotkeyEnum in src/types/hotkey.ts with a new hotkey identifier
- 2.Register the hotkey in HOTKEYS_REGISTRATION in src/const/hotkeys.ts with key combination and scope
- 3.Add i18n translations in src/locales/default/hotkey.ts with title and description
- 4.Create a custom hook in src/hooks/useHotkeys/ that uses useHotkeyById to bind the hotkey to an action
- 5.Register the hook in the appropriate scope hook (e.g., useRegisterChatHotkeys)
- 6.Optionally add a Tooltip component to UI elements to display the hotkey to users
Use cases
- Adding a new keyboard shortcut for clearing chat history (Cmd/Ctrl+Shift+Backspace)
- Creating chat-scoped hotkeys that only work in conversation context
- Implementing global hotkeys for system-wide actions
- Adding hotkey tooltips to buttons so users discover keyboard shortcuts
- Preventing hotkey conflicts with system and browser shortcuts
- LobeHub developers adding new features
- Contributors implementing keyboard navigation
- Developers customizing hotkey behavior for specific scopes
- Teams managing multi-language hotkey documentation
hotkey FAQ
Global scope hotkeys work anywhere in the application, while chat scope hotkeys only activate when in the conversation/chat context. Choose based on where the action should be available.
Key.Mod automatically resolves to Cmd on macOS and Ctrl on Windows/Linux, ensuring cross-platform compatibility without platform-specific code.
The HotkeyInput component shows warnings for conflicts. Verify your chosen combination doesn't conflict with system shortcuts (like Cmd+Q on macOS) or browser shortcuts.
Ensure the hotkey is added to HOTKEYS_REGISTRATION in src/const/hotkeys.ts and that the hook is properly registered in the appropriate scope hook.
The hotkey key combination is the same across languages, but the title and description are translated via i18n in src/locales/default/hotkey.ts.
Full instructions (SKILL.md)
Source of truth, from lobehub/lobehub.
name: hotkey description: 'Add or edit LobeHub keyboard shortcuts. Use for HotkeyEnum, HOTKEYS_REGISTRATION, combineKeys, useHotkeyById, tooltip hotkeys, shortcut scope, conflicts, or Cmd/Ctrl key combos.' user-invocable: false
Adding Keyboard Shortcuts Guide
Steps to Add a New Hotkey
1. Update Hotkey Constant
In src/types/hotkey.ts:
export const HotkeyEnum = {
// existing...
ClearChat: 'clearChat', // Add new
} as const;
2. Register Default Hotkey
In src/const/hotkeys.ts:
import { KeyMapEnum as Key, combineKeys } from '@lobehub/ui';
export const HOTKEYS_REGISTRATION: HotkeyRegistration = [
{
group: HotkeyGroupEnum.Conversation,
id: HotkeyEnum.ClearChat,
keys: combineKeys([Key.Mod, Key.Shift, Key.Backspace]),
scopes: [HotkeyScopeEnum.Chat],
},
];
3. Add i18n Translation
In src/locales/default/hotkey.ts:
const hotkey: HotkeyI18nTranslations = {
clearChat: {
desc: '清空当前会话的所有消息记录',
title: '清空聊天记录',
},
};
4. Create and Register Hook
In src/hooks/useHotkeys/chatScope.ts:
export const useClearChatHotkey = () => {
const clearMessages = useChatStore((s) => s.clearMessages);
return useHotkeyById(HotkeyEnum.ClearChat, clearMessages);
};
export const useRegisterChatHotkeys = () => {
useClearChatHotkey();
// ...other hotkeys
};
5. Add Tooltip (Optional)
const clearChatHotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.ClearChat));
<Tooltip hotkey={clearChatHotkey} title={t('clearChat.title', { ns: 'hotkey' })}>
<Button icon={<DeleteOutlined />} onClick={clearMessages} />
</Tooltip>;
Best Practices
- Scope: Choose global or chat scope based on functionality
- Grouping: Place in appropriate group (System/Layout/Conversation)
- Conflict check: Ensure no conflict with system/browser shortcuts
- Platform: Use
Key.Modinstead of hardcodedCtrlorCmd - Clear description: Provide title and description for users
Troubleshooting
- Not working: Check scope and RegisterHotkeys hook
- Not in settings: Verify HOTKEYS_REGISTRATION config
- Conflict: HotkeyInput component shows warnings
- Page-specific: Ensure correct scope activation
Related skills
More from lobehub/lobehub and the wider catalog.

i18n
Manage user-facing strings with react-i18next using flat dot-notation keys and zh-CN/en-US locales.

linear
Manage Linear issues from your code editor—link PRs, update status, and add completion comments.

microcopy
UI copy and microcopy guidelines for user-facing text, buttons, errors, and onboarding in Chinese and English.

modal
LobeHub imperative modal conventions for createModal, confirmModal, and base-ui modal APIs.

pr
Create a PR for the current branch (targets `canary` by default), including splitting one cross-layer branch into ordered stacked PRs so a lower layer (db / shared package / server TRPC) merges before its callers (desktop / CLI / UI). Use when the user asks to create / submit a PR, or to split a branch because clients call a server contract that isn't on the trunk yet. Triggers on 'pr', 'create pr', 'submit pr', 'open a PR', 'pull request', 'split this PR', 'stacked PR', 'backend should merge first', '提 PR', '提个 PR', '新建 PR', '拆 PR', '后端先合', '分层合并'.

project-overview
Navigate LobeHub's monorepo structure: locate code layers, understand app/package layout, and onboard to the repository.