true on macOS, false otherwise.
isMac(); // true on macOS
export function isMac(): boolean {
const uaData = (navigator as Navigator & { userAgentData?: { platform?: string } }).userAgentData;
if (uaData?.platform) return /mac/i.test(uaData.platform);
return /mac/i.test(navigator.platform);
}
Detects whether the current platform is macOS. Used to expand the
modtoken and to select themacbranch of a platform-awareKeyBinding. Falls back tonavigator.platformfor broad compatibility; the neweruserAgentDataAPI is preferred when available.