hotkey▌
lobehub/lobehub · updated Apr 8, 2026
Structured guide for implementing keyboard shortcuts in a chat application.
- ›Covers five-step implementation process: defining hotkey constants, registering default key combinations, adding i18n translations, creating and registering hooks, and optionally adding tooltips
- ›Supports scope-based hotkey management (global or chat-specific) with conflict detection and platform-agnostic key modifiers
- ›Includes best practices for grouping, conflict checking, and clear user descriptions, plus t
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
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.7★★★★★50 reviews- ★★★★★Noah Okafor· Dec 20, 2024
hotkey has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Noah Kim· Dec 12, 2024
hotkey fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Advait Kim· Dec 8, 2024
Registry listing for hotkey matched our evaluation — installs cleanly and behaves as described in the markdown.
- ★★★★★Chen Sethi· Dec 4, 2024
Keeps context tight: hotkey is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Arya Flores· Nov 27, 2024
Useful defaults in hotkey — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Aarav Perez· Nov 23, 2024
hotkey has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Yash Thakker· Nov 19, 2024
We added hotkey from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Henry Verma· Nov 19, 2024
hotkey fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Harper Wang· Nov 11, 2024
Keeps context tight: hotkey is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Dev Iyer· Oct 18, 2024
I recommend hotkey for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
showing 1-10 of 50