hotkey
π―SkillA step-by-step guide for adding keyboard shortcuts to the LobeHub app's code. It shows where to register a shortcut, add its translated name, connect it to an action and show it in a tooltip, while avoiding key conflicts.
Installation
npx skills add lobehub/lobehub --skill hotkeyRun it in a terminal; it asks which AI coding tools to install it for (Claude Code, Codex, Cursor and more).
Uses skills.sh Β· Node.js 22.20+
After installing
Ask for related work and the agent uses it on its own.
Install by hand
Copy the whole skill folder from GitHub to the place below. Copying only SKILL.md can leave out files the skill uses.
Open the skill folder β- This project
.claude/skills/hotkey/ - All projects
~/.claude/skills/hotkey/
These paths are for Claude Code. For other tools, the command above puts it in the right place.
SKILL.md
View on GitHub βUse for keyboard shortcuts, registration, key combinations, scope, conflicts and shortcut tooltips.
Adding Keyboard Shortcuts Guide
Steps to Add a New Hotkey
1. Update Hotkey Constant
In packages/types/src/hotkey.ts, add the new id to the HotkeyId union β it's the source of truth HotkeyEnum is typed against:
export type HotkeyId =
| 'addUserMessage'
// existing...
| 'saveTopic';
2. Register Default Hotkey
In packages/const/src/hotkeys.ts, KeyEnum and combineKeys are already defined locally in this file, so no import is needed β add the entry to HotkeyEnum and to HOTKEYS_REGISTRATION:
export const HotkeyEnum = {
// existing...
SaveTopic: 'saveTopic',
} as const satisfies Record<string, HotkeyId>;
export const HOTKEYS_REGISTRATION: HotkeyRegistration = [
// existing...
{
group: HotkeyGroupEnum.Conversation,
id: HotkeyEnum.SaveTopic,
keys: combineKeys([KeyEnum.Alt, 'n']),
scopes: [HotkeyScopeEnum.Chat],
},
];
3. Add i18n Translation
In packages/locales/src/default/hotkey.ts:
const hotkey: HotkeyI18nTranslations = {
saveTopic: {
desc: 'δΏεε½εθ―ι’εΉΆζ°ε»ΊδΈδΈͺθ―ι’',
title: 'δΏεθ―ι’',
},
};
4. Create and Register Hook
In src/hooks/useHotkeys/chatScope.ts:
export const useSaveTopicHotkey = () => {
const openNewTopicOrSaveTopic = useChatStore((s) => s.openNewTopicOrSaveTopic);
return useHotkeyById(HotkeyEnum.SaveTopic, openNewTopicOrSaveTopic);
};
export const useRegisterChatHotkeys = () => {
useSaveTopicHotkey();
// ...other hotkeys
};
5. Add Tooltip (Optional)
const saveTopicHotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.SaveTopic));
<Tooltip hotkey={saveTopicHotkey} title={t('saveTopic.title', { ns: 'hotkey' })}>
<Button icon={<SaveOutlined />} onClick={openNewTopicOrSaveTopic} />
</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
KeyEnum.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
More from this repository10
A style guide the AI follows when editing TypeScript files. It sets rules for safe types, imports, async code for file and network work, and how to export code so it stays easy to rename and reuse.
A guide for developers working on the LobeHub desktop app, which is built with Electron, a tool for making desktop apps with web code. It explains step by step where to put code when adding a desktop feature, and how to read the app's logs.
A map of the LobeHub open-source code for AI agents working on it. It explains which tools the project uses and where the apps, shared packages and main code live.
Automatically generates documentation for AI providers by extracting and formatting relevant details from provider configuration files.
Guides maintainers through releasing a new version of the project. It covers preparing the release pull request, following the rules that start an automatic release, and writing the GitHub Release notes. It does not write website changelog pages.
Skills for LobeHub, an open-source platform for building and collaborating with AI agent teammates. Covers React, TypeScript, Zustand state management, testing, and desktop app development within the LobeHub ecosystem.
Provides guidance and recommendations for implementing React best practices and optimizing web development workflows on Vercel
A guide for safely changing a database's structure with Drizzle, a TypeScript database tool. It covers schema rules, adding indexes without downtime, filling in existing data, SQL that can run twice safely, and fixing merge conflicts in change files.
A React coding guide for the LobeHub project that tells the AI how to write screen components. It explains which styling method to use, how to move old styles to StyleX, and how to keep screens fast.
Coding rules for managing app data with Zustand, a JavaScript library for shared app data, inside the LobeHub project. It explains how to shape data, write update logic, cache server data and test it.