I am trying to disable browser shortcuts while the user is trying to press a key combination in a SWF file. Although I can achieve this in Firefox, the code below does not work in IE 8. The code below can intercept keyboard events if the focus is not on the SWF file. However, I need to intercept keyboard events when the user is working with a SWF file.
function hookKeyboardEvents(e) { alert("hooked key"); // get key code var key_code = (window.event) ? event.keyCode : e.which; // case :if it is IE event if (window.event) { if (!event.shiftKey && !event.ctrlKey && !event.altKey) { window.event.returnValue = null; event.keyCode=0; } } // case: if it is firefox event else e.preventDefault(); document[flashId].keyDown(key_code); } window.document.onkeydown = hookKeyboardEvents;
The above code is never executed when the focus is on the SWF file.
javascript javascript-events dom-events internet-explorer-8 keyboard-events
Oki
source share