hotkey

Adding Keyboard Shortcuts Guide

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "hotkey" with this command: npx skills add lobehub/lobehub/lobehub-lobehub-hotkey

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;

  1. 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], }, ];

  1. Add i18n Translation

In src/locales/default/hotkey.ts :

const hotkey: HotkeyI18nTranslations = { clearChat: { desc: '清空当前会话的所有消息记录', title: '清空聊天记录', }, };

  1. 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 };

  1. 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.Mod instead of hardcoded Ctrl or Cmd

  • 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

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

react

No summary provided by upstream source.

Repository SourceNeeds Review
1.3K-lobehub
General

zustand

No summary provided by upstream source.

Repository SourceNeeds Review
General

project-overview

No summary provided by upstream source.

Repository SourceNeeds Review
General

i18n

No summary provided by upstream source.

Repository SourceNeeds Review