MCPcopy
hub / github.com/ZToolsCenter/ZTools / buildShortcutString

Method buildShortcutString

src/main/managers/windowManager.ts:1420–1444  ·  view source on GitHub ↗

* 从 input 事件构建快捷键字符串

(input: Electron.Input)

Source from the content-addressed store, hash-verified

1418 * 从 input 事件构建快捷键字符串
1419 */
1420 private buildShortcutString(input: Electron.Input): string {
1421 const keys: string[] = []
1422
1423 // 修饰键(按标准顺序)
1424 if (input.meta) {
1425 keys.push(platform.isMacOS ? 'Command' : 'Meta')
1426 }
1427 if (input.control) {
1428 keys.push(platform.isMacOS ? 'Ctrl' : 'Ctrl')
1429 }
1430 if (input.alt) {
1431 keys.push(platform.isMacOS ? 'Option' : 'Alt')
1432 }
1433 if (input.shift) {
1434 keys.push('Shift')
1435 }
1436
1437 // 主键(转换为标准格式)
1438 const mainKey = this.normalizeKey(input.key)
1439 if (mainKey && !WindowManager.MODIFIER_NAMES.includes(mainKey)) {
1440 keys.push(mainKey)
1441 }
1442
1443 return keys.join('+')
1444 }
1445
1446 /**
1447 * 标准化按键名称

Callers 1

createWindowMethod · 0.95

Calls 1

normalizeKeyMethod · 0.95

Tested by

no test coverage detected