Render shortcuts with Apple's modifier and key glyphs #4701
Closedcolonelpanic8(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/4701/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/keybindings.ts lines 225 to 227Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -216,3 +216,11 @@216216 return null;217217 }218218219+/**220+ * Apple's glyphs for the non-letter keys, from Apple's Human Interface221+ * Guidelines. Keys with no established glyph (function keys, punctuation) keep222+ * their word form.223+ */224+const SHORTCUT_KEY_SYMBOLS: Readonly<Record<string, string>> = {225+ " ": "␣",226+ arrowdown: "↓",
- @@ -229 +249,21 @@229249250+/**251+ * Apple-style glyph for one token of a raw binding string ("mod+shift+b"), for252+ * surfaces that render a chord as separate chips rather than one label.253+ */254+export function formatShortcutTokenLabel(token: string, platform = navigator.platform): string {255+ const useMetaForMod = isMacPlatform(platform);256+ switch (token) {257+ case "mod":258+ return useMetaForMod ? "⌘" : "⌃";259+ case "meta":260+ return useMetaForMod ? "⌘" : "Super";261+ case "ctrl":262+ return "⌃";263+ case "alt":264+ return "⌥";265+ case "shift":266+ return "⇧";267+ default:268+ return formatShortcutKeyLabel(token);269+ }@@ -238,14 +283,7 @@238- const showAlt = shortcut.altKey;239- const showShift = shortcut.shiftKey;240-241- if (useMetaForMod) {242- return `${showCtrl ? "\u2303" : ""}${showAlt ? "\u2325" : ""}${showShift ? "\u21e7" : ""}${showMeta ? "\u2318" : ""}${keyLabel}`;243- }244-245- const parts: string[] = [];246- if (showCtrl) parts.push("Ctrl");247- if (showAlt) parts.push("Alt");248- if (showShift) parts.push("Shift");249- if (showMeta) parts.push("Meta");250- parts.push(keyLabel);251- return parts.join("+");283+ return [284+ shortcut.ctrlKey || (shortcut.modKey && !useMetaForMod) ? "⌃" : "",285+ shortcut.altKey ? "⌥" : "",286+ shortcut.shiftKey ? "⇧" : "",287+ shortcut.metaKey || (shortcut.modKey && useMetaForMod) ? (useMetaForMod ? "⌘" : "Super") : "",288+ formatShortcutKeyLabel(shortcut.key),289+ ].join("");
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.




Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
07a894d4-c875-4170-ae7b-b3f2d46fe73bYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share