我有一个 Web 应用程序,其中有一段快捷方式代码,在 chrome 和 firefox 中都可以正常工作。我如何将其扩展到适用于 chrome 和 firefox 的 Mac 机器。
窗口中的代码
$(document).bind("keydown","Ctrl+s", function() {
//Save code
alert("Save");
});
对于mac,我尝试了下面的一段代码,它工作正常。
$(document).bind("keydown","meta+s", function() {
//Save code
alert("Save");
});
我可以做到这一点的另一种方法是对两者都有一个共同的功能,如下所示
var save = function(event) {
//save code
return false;
};
$(document).bind("keydown","Ctrl+s", save);
$(document).bind("keydown","meta+s", save);
让我知道任何其他更好的方法来做到这一点,它适用于 chrome 和 firefox 中的 windows 和 mac。