I have a Flex app running on a web page, and I want to use the Command+← key combination to trigger certain actions in the app. This is fine on most browsers, but on Safari, the browser intercepts this keyboard event and causes the browser "back" event instead. Is there a way, either through Flex or via JavaScript elsewhere on the page, that I can tell Safari not to do that?
Short answer, it's a (little) known bug on non-mac versions of safari. You can't reliably block all shortcut keys. Perhaps if you were more specific about what other shortcuts you're trying to block? Maybe some of them will work. e.g. cut paste copy have their own special methods of blocking. (Although it seems like you probably already know that.)
Are you using something like this?
function blockKeys(e) {
var blocked = new Array('c','x','v');
var keyCode = (e.keyCode) ? e.keyCode : e.which;
var isCtrl;
if(window.event)
isCtrl = e.ctrlKey
else
isCtrl = (window.Event) ? ((e.modifiers & Event.CTRL_MASK) == Event.CTRL_MASK) : false;
if(isCtrl) {
for(i = 0; i < blocked.length; i++) {
if(blocked[i] == String.fromCharCode(keyCode).toLowerCase()) {
return false;
}
}
}
return true;
}
You're not the first to get hit with this bug on here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With