# Register and Manage Keyboard Shortcut for Saving and Creating Topics in Chat Interfaces

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.

**Canonical 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

**Instructions download URL:** https://skillshunter.net/skills/github-lobehub-lobehub-agents-skills-hotkey-4245770a778c/download

**Category:** Software & Development

**Source URL:** https://github.com/lobehub/lobehub/blob/54382b5c8e81544da454fa6d7b50f461a562c1ee/.agents/skills/hotkey/SKILL.md

**Source commit:** 54382b5c8e81544da454fa6d7b50f461a562c1ee

**Listing approved at:** 2026-11-22

**Created at:** 2026-11-21T11:16:14.000000Z

**Updated at:** 2026-11-22T11:17:05.000000Z

## Catalog information

The following descriptions are catalog information. Listing approval does not mean the skill has been tested or is safe for every environment.

### Editor's 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.

### When to use it

- Allow users to save the current topic and create a new one using a custom keyboard shortcut.

## Skill instructions

---
name: hotkey
description: 'Use for keyboard shortcuts, registration, key combinations, scope, conflicts and shortcut tooltips.'
user-invocable: false
---

# 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:

```typescript
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`:

```typescript
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`:

```typescript
const hotkey: HotkeyI18nTranslations = {
  saveTopic: {
    desc: '保存当前话题并新建一个话题',
    title: '保存话题',
  },
};
```

### 4. Create and Register Hook

In `src/hooks/useHotkeys/chatScope.ts`:

```typescript
export const useSaveTopicHotkey = () => {
  const openNewTopicOrSaveTopic = useChatStore((s) => s.openNewTopicOrSaveTopic);
  return useHotkeyById(HotkeyEnum.SaveTopic, openNewTopicOrSaveTopic);
};

export const useRegisterChatHotkeys = () => {
  useSaveTopicHotkey();
  // ...other hotkeys
};
```

### 5. Add Tooltip (Optional)

```tsx
const saveTopicHotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.SaveTopic));

<Tooltip hotkey={saveTopicHotkey} title={t('saveTopic.title', { ns: 'hotkey' })}>
  <Button icon={<SaveOutlined />} onClick={openNewTopicOrSaveTopic} />
</Tooltip>;
```

## Best Practices

1. **Scope**: Choose global or chat scope based on functionality
2. **Grouping**: Place in appropriate group (System/Layout/Conversation)
3. **Conflict check**: Ensure no conflict with system/browser shortcuts
4. **Platform**: Use `KeyEnum.Mod` instead of hardcoded `Ctrl` or `Cmd`
5. **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

