ChemPal Documentation - v1.7.0
    Preparing search index...

    Function isMac

    • Detects whether the current platform is macOS. Used to expand the mod token and to select the mac branch of a platform-aware KeyBinding. Falls back to navigator.platform for broad compatibility; the newer userAgentData API is preferred when available.

      Returns boolean

      true on macOS, false otherwise.

      isMac(); // true on macOS
      
      export function isMac(): boolean {
      // `userAgentData` is a not-yet-standardized browser API absent from the DOM lib types;
      // widen the trusted `navigator` global to read it safely.
      const uaData = (navigator as Navigator & { userAgentData?: { platform?: string } }).userAgentData;
      if (uaData?.platform) return /mac/i.test(uaData.platform);
      return /mac/i.test(navigator.platform);
      }