I need to show users that to paste they need to do it using keyboard commands. However, the paste command is different on Mac as it is on Windows and I need to be able to detect that. What is the correct way of doing this in JavaScript WITHOUT having to do OS checks (as that can be faked, thus why we no longer do browser checks)
Asked
Active
Viewed 150 times
1 Answers
0
Have you had a look to this question; How does one capture a Mac's command key via JavaScript?
If you detect the window.navigator.platform
of the user, it will tell you which platform the user is using. You can read up on how to use it here.
Summarizing, you can detect it like this:
var isMacLike = navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i);
var isIOS = navigator.platform.match(/(iPhone|iPod|iPad)/i);
if(isMacLike || isIOS ){
//MAC (remove isIos if you dont care about iphone/ipod/ipad)
}
else{ //other O.S.
//close button on right side
}

Community
- 1
- 1

avcajaraville
- 9,041
- 2
- 28
- 37
-
How does this apply to the question? He can't make the user type the short-cut and then detect it. He wants to *teach* the user. – Álvaro González Jul 18 '14 at 12:30
-
He wants to detect copy/paste through key detections, and thats a way of detect the cmd key, isnt ? If he successfully detect a cmd key, means you have an Mac, right ? Thats the way I understood it – avcajaraville Jul 18 '14 at 12:31