I’ve found a couple questions about this on here, but can’t find a solution.
//Add keyboard shortcuts for convenience.
self.iframe.addEventListener('keydown', function(e){
//Check for alt+p and make sure were not in fullscreen
if(e.altKey && e.keyCode === 80 && !fullScreenApi.isFullScreen()){
self.preview();
}
//Because Macs e == 69, but alt+e == 229 which is the ´ character,
if(e.altKey && e.keyCode === 69 || e.keyCode === 229){
e.preventDefault ? e.preventDefault() : e.returnValue = false;
console.log(e.returnValue);
if(!fullScreenApi.isFullScreen()){
self.edit();
}
}
//Check for alt+f
if(e.altKey && e.keyCode === 70){
e.preventDefault ? e.preventDefault() : e.returnValue = false;
fullScreenApi.requestFullScreen(fsElement);
}
});
What I am trying to do is cancel the default action for alt+E in internet explorer 9. currently it is accomplishing what I want it to do, but at the same time dropping the “edit” menu down. I found online people using the e.returnValue = false as a solution, but that didn’t seem to work. The console.log(e.returnValue) returned undefined.
Thanks in advance!
It may very well be that there is no way to do this in IE. I remember struggling with trying to create an event handler that would handle ctrl + click. Unfortunately, in IE this spawns a new browser tab, and the behavior is hard-coded into the browser, seemingly independent of its JS engine.
Normally preventDefault would do the trick, but if it doesn’t, you may want to consider whether you could use a different keyboard shortcut for IE users, in case the default is not at all preventable.
EDIT: Although, you may want to try using stopPropagation() in conjunction with preventDefault(). Can’t guarantee it will help, but it might.