I have a webapp that tells the user to copy and paste something. I want to show them the keyboard shortcut for it. How would I find out if it's
Ctrl+C and V, or
⌘+C and V, or even something different?
Asked
Active
Viewed 28 times
1
![](../../users/profiles/2585092.webp)
yspreen
- 1,167
- 2
- 12
- 25
-
1Try this https://stackoverflow.com/questions/9514179/how-to-find-the-operating-system-version-using-javascript – Allan Apr 27 '18 at 10:48
2 Answers
0
I guess you will need to handle this yourself. You can get current user system like this:
var platform = window.navigator.platform;
console.log(platform);
if (platform.startsWith('Mac')) {
console.log('use CMD + V');
} else if (platform.startsWith('Win')) {
console.log('use CTRL + V');
} else {
// ...
}
![](../../users/profiles/3665878.webp)
Martin Adámek
- 12,431
- 5
- 25
- 47
-
Shame, I thought there may be some nice solution. Are you sure that all apple platforms start with `Mac`? – yspreen Apr 27 '18 at 10:51
-
not 100% sure, but i would bet that all intel mac computers (so all models of last decade) will have `MacIntel` as main do. – Martin Adámek Apr 27 '18 at 10:53
-
note that iOS devices have different platform, but there is no CMD key – Martin Adámek Apr 27 '18 at 10:53
0
You could get the platform using window.navigator.platform
and if the returned value contains 'mac' you can assume it is MacOS else if it contains 'win' it is windows.
![](../../users/profiles/9705617.webp)
JodyL
- 164
- 1