views:

545

answers:

0

I am trying to disable browser shortcuts while user tries to press some combination of keys on the swf file. Although I can achieve this in firefox, below code does not function in ie 8. Below code is able to hook the keyboard events if focus is not on the swf file. However, what I need is hooking keyboard events when user operates on 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;

Above code never executes when focus is on swf file.

related questions