MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / formatKeyToken

Function formatKeyToken

packages/app-core/src/lib/keymaps.ts:1431–1454  ·  view source on GitHub ↗
(token: string, mac = isMacPlatform())

Source from the content-addressed store, hash-verified

1429}
1430
1431export function formatKeyToken(token: string, mac = isMacPlatform()): string {
1432 if (token.includes("+")) {
1433 const parts = token.split("+");
1434 const base = parts.pop() ?? token;
1435 const prefix = parts
1436 .map((part) => formatKeyToken(part, mac))
1437 .join(mac ? "" : "+");
1438 return `${prefix}${mac ? "" : prefix ? "+" : ""}${formatKeyToken(base, mac)}`;
1439 }
1440 if (token === "Mod") return mac ? "⌘" : "Ctrl";
1441 if (token === "Meta") return mac ? "⌘" : "Meta";
1442 if (token === "Ctrl") return mac ? "⌃" : "Ctrl";
1443 if (token === "Alt") return mac ? "⌥" : "Alt";
1444 if (token === "Shift") return mac ? "⇧" : "Shift";
1445 if (token === "Escape" || token === "Esc") return "Esc";
1446 if (token === "Enter") return mac ? "↵" : "Enter";
1447 if (token === "Tab") return "Tab";
1448 if (token === "Space") return "Space";
1449 if (token === "ArrowUp") return "↑";
1450 if (token === "ArrowDown") return "↓";
1451 if (token === "ArrowLeft") return "←";
1452 if (token === "ArrowRight") return "→";
1453 return token;
1454}
1455
1456export function formatKeymapBinding(binding: string, kind: KeymapKind): string {
1457 if (kind === "shortcut") {

Callers 4

buildEditorContextItemsFunction · 0.90
KeyCapFunction · 0.90
EditorSelectionToolbarFunction · 0.90
formatKeymapBindingFunction · 0.85

Calls 1

isMacPlatformFunction · 0.85

Tested by

no test coverage detected