Docs
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
Hotkeys API Reference
App Hotkeys API Reference
Key hold & held keys API Reference
Hotkey Recorder API Reference
Normalization & format API Reference

detectPlatform

ts
function detectPlatform(): "mac" | "windows" | "linux";
function detectPlatform(): "mac" | "windows" | "linux";

Defined in: platform.ts:18

Detects the current platform based on browser navigator properties.

Used internally to resolve platform-adaptive modifiers like 'Mod' (Command on Mac, Control elsewhere) and for platform-specific hotkey formatting.

Returns

"mac" | "windows" | "linux"

The detected platform: 'mac', 'windows', or 'linux'

Remarks

Defaults to 'linux' in SSR environments where navigator is undefined

Example

ts
const platform = detectPlatform() // 'mac' | 'windows' | 'linux'
const modifier = resolveModifier('Mod', platform) // 'Meta' on Mac, 'Control' elsewhere
const platform = detectPlatform() // 'mac' | 'windows' | 'linux'
const modifier = resolveModifier('Mod', platform) // 'Meta' on Mac, 'Control' elsewhere