I'm writing javascript code for a web emulator containing function keys. The user is able to press keyboard function keys to process something in the emulator, I used stopPropagation and preventDefault javascript function to stop/cancel browsers invoking their function key shortcut (e.g. F1 will invoke Firefox to open its help page) and the code works fine under Firefox and Chrome. But Opera didn't work, Opera invokes both my function and launches Opera help page. I'm using latest Opera 10.5 here. Can anyone help ?
this code is in FireFox javascript handle and this is attached in main body HTML onkeydown event:
function KeyHandler(ev)
{
if(112==ev.keyCode) {InvokeF1();return CancelKey(ev);}
if(113==ev.keyCode) {InvokeF2();return CancelKey(ev);}
...
}
function CancelKey(ev)
{
ev.stopPropagation();
ev.preventDefault();
}
IE used different code for CancelKey, which use ev.CancelBubble = true and ev.returnValue = false.