(Encountered while writing this script )
Relevant code:
window.keyPressEventLambda=function(key,callback){ //just a lambda function wrapper so I can generate handlers on the fly
return function (zEvent) {
if (zEvent.altKey && ( zEvent.which == key.charCodeAt(0)||zEvent.which == key.toUpperCase().charCodeAt(0))) {
callback(this.id);
return false;
}
return true;
}
}
Use case:
$("textarea").live("keydown",keyPressEventLambda("C",function(id){/*blah blah blah */})
So, if I use Alt-C, the callback function runs itself.
Now, due to the return false;
, bubbling is suppressed and everything is handy-dandy within the page itself.
But, Chrome (20.0.1128.0 or 19.0.1084.41 on Windows), still captures the alt key as a Chrome browser shortcut, and, since no shortcut actually exists for Alt-C, it fails and makes an annoying "ping" sound.
It works fine for Ctrl-shortcuts, but I don't want to use these since most of the Ctrl-shortcuts are taken.
Is there any way to prevent the browser from getting angry at my script?
This is a known Chrome-issue. See http://code.google.com/p/chromium/issues/detail?id=105500