(mod: ModifierKey)
| 295 | type ModifierKey = (typeof MODIFIERS)[number]; |
| 296 | |
| 297 | const modifierKeyText = (mod: ModifierKey) => { |
| 298 | const isMac = navigator.userAgent.search("Mac") !== -1; |
| 299 | if (mod === "cmd" || (mod === "cmd_or_ctrl" && isMac)) { |
| 300 | return "⌘"; // U+2318 |
| 301 | } |
| 302 | if (mod === "ctrl" && isMac) { |
| 303 | return "⌃"; // U+2303 |
| 304 | } |
| 305 | if ((mod === "ctrl" && !isMac) || (mod === "cmd_or_ctrl" && !isMac)) { |
| 306 | return "Ctrl"; |
| 307 | } |
| 308 | if (mod === "opt" || (mod === "opt_or_alt" && isMac)) { |
| 309 | return "⌥"; // U+2325 |
| 310 | } |
| 311 | if (mod === "alt" || (mod === "opt_or_alt" && !isMac)) { |
| 312 | return "Alt"; |
| 313 | } |
| 314 | if (mod === "shift" && isMac) { |
| 315 | return "⇧"; // U+21E7 |
| 316 | } |
| 317 | if (mod === "shift" && !isMac) { |
| 318 | return "Shift"; |
| 319 | } |
| 320 | console.assert(false, "should never reach this line"); |
| 321 | return ""; |
| 322 | }; |
| 323 | |
| 324 | export const keyboardShortcutStr = (str: string) => { |
| 325 | const parts = str.split("+"); |
no outgoing calls
no test coverage detected