{"data":{"slug":"github-lobehub-lobehub-agents-skills-hotkey-4245770a778c","title":"Register and Manage Keyboard Shortcut for Saving and Creating Topics in Chat Interfaces","summary":"Register a new keyboard shortcut for saving and creating new topics in chat interfaces using the Hotkey system. The process includes defining the shortcut, adding translations, and registering the hotkey in the application.","url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-hotkey-4245770a778c","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-lobehub-lobehub-agents-skills-hotkey-4245770a778c","markdown_url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-hotkey-4245770a778c.md","download_url":"https:\/\/skillshunter.net\/skills\/github-lobehub-lobehub-agents-skills-hotkey-4245770a778c\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Ensure the `HotkeyId` union is updated in `hotkey.ts` before adding the new shortcut. Also, verify that the `HOTKEYS_REGISTRATION` array includes the new hotkey configuration with the correct scope and key combination.","instructions":"---\nname: hotkey\ndescription: 'Use for keyboard shortcuts, registration, key combinations, scope, conflicts and shortcut tooltips.'\nuser-invocable: false\n---\n\n# Adding Keyboard Shortcuts Guide\n\n## Steps to Add a New Hotkey\n\n### 1. Update Hotkey Constant\n\nIn `packages\/types\/src\/hotkey.ts`, add the new id to the `HotkeyId` union \u2014 it's the source of truth `HotkeyEnum` is typed against:\n\n```typescript\nexport type HotkeyId =\n  | 'addUserMessage'\n  \/\/ existing...\n  | 'saveTopic';\n```\n\n### 2. Register Default Hotkey\n\nIn `packages\/const\/src\/hotkeys.ts`, `KeyEnum` and `combineKeys` are already defined locally in this file, so no import is needed \u2014 add the entry to `HotkeyEnum` and to `HOTKEYS_REGISTRATION`:\n\n```typescript\nexport const HotkeyEnum = {\n  \/\/ existing...\n  SaveTopic: 'saveTopic',\n} as const satisfies Record<string, HotkeyId>;\n\nexport const HOTKEYS_REGISTRATION: HotkeyRegistration = [\n  \/\/ existing...\n  {\n    group: HotkeyGroupEnum.Conversation,\n    id: HotkeyEnum.SaveTopic,\n    keys: combineKeys([KeyEnum.Alt, 'n']),\n    scopes: [HotkeyScopeEnum.Chat],\n  },\n];\n```\n\n### 3. Add i18n Translation\n\nIn `packages\/locales\/src\/default\/hotkey.ts`:\n\n```typescript\nconst hotkey: HotkeyI18nTranslations = {\n  saveTopic: {\n    desc: '\u4fdd\u5b58\u5f53\u524d\u8bdd\u9898\u5e76\u65b0\u5efa\u4e00\u4e2a\u8bdd\u9898',\n    title: '\u4fdd\u5b58\u8bdd\u9898',\n  },\n};\n```\n\n### 4. Create and Register Hook\n\nIn `src\/hooks\/useHotkeys\/chatScope.ts`:\n\n```typescript\nexport const useSaveTopicHotkey = () => {\n  const openNewTopicOrSaveTopic = useChatStore((s) => s.openNewTopicOrSaveTopic);\n  return useHotkeyById(HotkeyEnum.SaveTopic, openNewTopicOrSaveTopic);\n};\n\nexport const useRegisterChatHotkeys = () => {\n  useSaveTopicHotkey();\n  \/\/ ...other hotkeys\n};\n```\n\n### 5. Add Tooltip (Optional)\n\n```tsx\nconst saveTopicHotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.SaveTopic));\n\n<Tooltip hotkey={saveTopicHotkey} title={t('saveTopic.title', { ns: 'hotkey' })}>\n  <Button icon={<SaveOutlined \/>} onClick={openNewTopicOrSaveTopic} \/>\n<\/Tooltip>;\n```\n\n## Best Practices\n\n1. **Scope**: Choose global or chat scope based on functionality\n2. **Grouping**: Place in appropriate group (System\/Layout\/Conversation)\n3. **Conflict check**: Ensure no conflict with system\/browser shortcuts\n4. **Platform**: Use `KeyEnum.Mod` instead of hardcoded `Ctrl` or `Cmd`\n5. **Clear description**: Provide title and description for users\n\n## Troubleshooting\n\n- **Not working**: Check scope and RegisterHotkeys hook\n- **Not in settings**: Verify HOTKEYS\\_REGISTRATION config\n- **Conflict**: HotkeyInput component shows warnings\n- **Page-specific**: Ensure correct scope activation\n","use_cases":["Allow users to save the current topic and create a new one using a custom keyboard shortcut."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/lobehub\/lobehub\/blob\/54382b5c8e81544da454fa6d7b50f461a562c1ee\/.agents\/skills\/hotkey\/SKILL.md","source_commit":"54382b5c8e81544da454fa6d7b50f461a562c1ee","license":null,"version":null,"listing_approved_at":"2026-11-22","created_at":"2026-11-21T11:16:14.000000Z","updated_at":"2026-11-22T11:17:05.000000Z","seo_title":"Register Keyboard Shortcut for Saving Topics","seo_description":"Learn how to register a keyboard shortcut for saving and creating new topics in chat interfaces using the Hotkey system.","seo_keywords":["register keyboard shortcut","save topic shortcut","hotkey registration","chat shortcut creation"]}}