MCPcopy Create free account
hub / github.com/Bistutu/FluentRead / generateDisplayName

Function generateDisplayName

entrypoints/utils/hotkey.ts:175–195  ·  view source on GitHub ↗

* 生成快捷键显示名称 * @param modifiers 修饰键数组 * @param key 普通按键 * @returns 显示名称

(modifiers: string[], key: string)

Source from the content-addressed store, hash-verified

173 * @returns 显示名称
174 */
175function generateDisplayName(modifiers: string[], key: string): string {
176 const isMac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
177 const modifierDisplayNames: Record<string, string> = isMac ?
178 {
179 ctrl: 'Control',
180 alt: 'Option',
181 shift: 'Shift',
182 meta: 'Cmd'
183 } :
184 {
185 ctrl: 'Ctrl',
186 alt: 'Alt',
187 shift: 'Shift',
188 meta: 'Win'
189 };
190
191 const keyDisplayName = key.charAt(0).toUpperCase() + key.slice(1);
192 const modifierNames = modifiers.map(mod => modifierDisplayNames[mod] || mod);
193
194 return [...modifierNames, keyDisplayName].join('+');
195}
196
197/**
198 * 检查事件是否匹配指定的快捷键

Callers 1

parseHotkeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected