Why keypressdoesn't the event below work in Chrome and Safari? It works great in Firefox!
Did I miss something for Chrome and Safari?
$(window).keypress(function(event) {
if ((event.which == 115 && event.ctrlKey) || (event.which == 19)) {
$("form input[type=submit][name=update]",object_popup).click();
alert("Keys down are Ctrl + s + Return");
} else if ((event.which == 120 && event.ctrlKey) || (event.which == 19)){
$(".ps-button-close",object_popup).click();
alert("Keys down are Ctrl + x + Return");
} else {
return true;
}
event.preventDefault();
return false;
});
Chrome / Safari will revert to default and save the webpage instead when I use ctl + s and the warning sound when I use ctl + x.
jsFiddle Demo
source
share