| 22 | } |
| 23 | |
| 24 | function resolveDisplayPlatform(): DisplayPlatform { |
| 25 | if (cachedDisplayPlatform) { |
| 26 | return cachedDisplayPlatform |
| 27 | } |
| 28 | |
| 29 | if (typeof navigator === 'undefined') { |
| 30 | cachedDisplayPlatform = 'default' |
| 31 | return cachedDisplayPlatform |
| 32 | } |
| 33 | |
| 34 | const navigatorWithUserAgentData = navigator as Navigator & { |
| 35 | userAgentData?: { platform?: string } |
| 36 | } |
| 37 | const platformHint = [ |
| 38 | navigatorWithUserAgentData.userAgentData?.platform, |
| 39 | navigator.platform, |
| 40 | navigator.userAgent |
| 41 | ] |
| 42 | .filter(Boolean) |
| 43 | .join(' ') |
| 44 | .toLowerCase() |
| 45 | |
| 46 | cachedDisplayPlatform = platformHint.includes('mac') ? 'darwin' : 'default' |
| 47 | return cachedDisplayPlatform |
| 48 | } |
| 49 | |
| 50 | export function getShortcutLabel(id: ShortcutLabelId): string { |
| 51 | const modifier = resolveDisplayPlatform() === 'darwin' ? 'Cmd' : 'Ctrl' |