I know that this question was asked by serval times here in stackoverflow, and I tried several different solutions, but cannot find the code that works for me.
I want to grab the keyboard command Ctrl+ Sand Command+ Son a Mac, I am currently using this code (since jQuery 2.1.0):
jQuery(window).on('keypress', function(event){
if (!(event.which == 115 && (event.ctrlKey||event.metaKey)) && !(event.which == 19)) return true;
event.preventDefault();
return false;
});
This code works fine in:
- Safari: c Ctrl+ Sand Command+S
- Firefox: c Ctrl+ Sand Command+S
- Chrome: Only Ctrl + Sworks
You will see that the problem is with Google Chrome, here I can only capture Ctrl+ S.
Does anyone know how I can solve this problem?