Disable default handling Ctrl + O in Internet Explorer

I am trying to disable IE default processing by Ctrl + O.

I have an onKeyDown handler that gets called, but although I call event.cancelBubble and return false , the default command is File | Open is still running.

btw: this is not critical, since I can just choose a different key, but curious if there could be a way around this.

+4
source share
1 answer

First, you cannot call event.cancelBubble , this is not a method, but a property that you can set to true .

To prevent special keys from working in IE by default, you also need to set the IE key code to 0:

 function keydownHandler(e) { e = e || window.event; if (e.preventDefault) e.preventDefault(); else { e.cancelBubble = true; e.returnValue = false; e.keyCode = 0; } } 
+4
source

All Articles