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

Function normalizeShortcutBinding

packages/app-core/src/lib/keymaps.ts:1238–1260  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

1236}
1237
1238export function normalizeShortcutBinding(input: string): string | null {
1239 const mac = isMacPlatform();
1240 const parts = input
1241 .split("+")
1242 .map((part) => part.trim())
1243 .filter(Boolean);
1244 if (parts.length === 0) return null;
1245 const rawKey = parts.pop();
1246 if (!rawKey) return null;
1247 const key = normalizeKeyName(rawKey);
1248 if (!key) return null;
1249 const modifiers = normalizeModifiers(parts.flatMap((part) => {
1250 const normalized = normalizeModifierToken(part);
1251 if (!normalized) return [];
1252 // Canonicalize the platform-primary modifier to `Mod` so stored
1253 // shortcut bindings remain portable across the renderer and the
1254 // key recorder. Keep the non-primary modifier explicit.
1255 if (normalized === "Meta") return [mac ? "Mod" : "Meta"];
1256 if (normalized === "Ctrl") return [mac ? "Ctrl" : "Mod"];
1257 return [normalized];
1258 }));
1259 return [...modifiers, key].join("+");
1260}
1261
1262export function normalizeSequenceToken(input: string): string | null {
1263 const parts = input

Callers 3

keymaps.tsFile · 0.85
normalizeKeymapBindingFunction · 0.85
shortcutBindingFromEventFunction · 0.85

Calls 4

isMacPlatformFunction · 0.85
normalizeKeyNameFunction · 0.85
normalizeModifiersFunction · 0.85
normalizeModifierTokenFunction · 0.85

Tested by

no test coverage detected