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 40 times
        
    1
            
            
         
    
    
        yspreen
        
- 1,759
- 2
- 20
- 44
- 
                    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 {
  // ...
} 
    
    
        Martin Adámek
        
- 16,771
- 5
- 45
- 64
- 
                    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.
 
    
    
        JodyL
        
- 184
- 1