~james/core

core/web/src/lib/components/ui/keyLabels.ts -rw-r--r-- 407 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
export type KeyName = "mod" | "shift" | "enter";

const MAC_LABELS: Record<KeyName, string> = { mod: "⌘", shift: "⇧", enter: "⏎" };
const LABELS: Record<KeyName, string> = { mod: "Ctrl", shift: "Shift", enter: "Enter" };

export const isMac = (): boolean => /Mac|iPhone|iPad/.test(navigator.platform);

export const keyLabel = (key: KeyName, mac: boolean): string => (mac ? MAC_LABELS : LABELS)[key];