0

betaveros.bearblog.dev · 7d · discuss

Often, you should just use feature detection instead of asking this question. But if your underlying question is "does the user expect Control or Command as a modifier key?", there's currently (November 2026) no good alternative. The short answer: const isApple = /Mac|iPod|iPhone|iPad/.test(navigator.platform); const isModified = (event) => isApple ? event.metaKey : event.ctrlKey; const modifierLabel = isApple ? "⌘" : "Ctrl"; (Even then, you might just want to check either metaKey or ctrlKey, it depends. Somebody has proposed a shortcut key constant over at w3c/uievents#412, but it doesn't appear to have gained traction.) navigator.platform seems fine to use now, but...