"use client" import * as React from "react" const noopSubscribe = () => () => {} function isApplePlatform() { return typeof navigator !== "undefined" && /Mac|iPhone|iPod|iPad/i.test(navigator.platform) } /** * The platform is a fact about the browser, not state: read it as an external * snapshot. The server snapshot is the Apple label, so server and first client * render agree and a non-Apple client corrects on hydration without a mismatch. */ function usePlatformLabel(apple: string, other: string) { return React.useSyncExternalStore( noopSubscribe, () => (isApplePlatform() ? apple : other), () => apple, ) } /** "⌘" on Apple platforms, "Ctrl" elsewhere — for `Kbd` tooltips. */ export function useModKeyLabel() { return usePlatformLabel("⌘", "Ctrl") } /** "⌥" on Apple platforms, "Alt" elsewhere — pair with `useModKeyLabel` for ⌘⌥ / Ctrl+Alt chords. */ export function useAltKeyLabel() { return usePlatformLabel("⌥", "Alt") }