lobehub avatar

Hotkey

Step-by-step guide for registering a new keyboard shortcut across types, constants, i18n, and hooks.

skills.sh installs
4.1K
GitHub stars
86K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers the full registration flow: HotkeyId union, HotkeyEnum, HOTKEYS_REGISTRATION, i18n translations, and a hook
  • Includes a tooltip pattern that displays a shortcut next to a button using Tooltip and hotkey
  • Enforces KeyEnum.Mod over hardcoded Ctrl or Cmd and requires scope and group selection
  • Designed for LobeHub contributors adding or troubleshooting shortcuts with scope, conflict, or settings issues

Install

$ npx -y skills add lobehub/lobehub --skill hotkey -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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

Details

Repository
github.com/lobehub/lobehub
Category
Frontend & UI Code
First seen
Apr 16, 2026

More from lobehub/lobehub

All 21

Similar to Hotkey

More Frontend & UI Code