Kevin Powell - CommunityKP-C
Kevin Powell - Community3y ago
10 replies
lko

How do you know if the user is using a Mac?

So I found this code online:
window.navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey

The problem is that platform is deprecated, what can I use instead? This is the entire code, basically i'm trying to run a function if the user presses CTRL + S or CMD + S ofc
    if (
      (window.navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey) &&
      e.keyCode == 83
    ) {
      e.preventDefault();
      validate();
    }
Was this page helpful?