1

I had an web application which had piece of code for shortcuts which is working fine for windows in both chrome and firefox. How can i extend this to Mac machine for both chrome and firefox.

Code in windows

$(document).bind("keydown","Ctrl+s", function() {
       //Save code
       alert("Save");
});

For mac i tried below piece of code which is working fine.

$(document).bind("keydown","meta+s", function() {
       //Save code
       alert("Save");
});

The other way i can do this is by having a common function for both like as below

var save = function(event) {
   //save code
   return false;
};

$(document).bind("keydown","Ctrl+s", save);
$(document).bind("keydown","meta+s", save);

Let me know any other better way to do this which works for both windows and mac in chrome and firefox.

CNKR
  • 568
  • 5
  • 19

0 Answers0