I am writing javascript code for a web emulator containing function keys. The user can press the keyboard function keys to process something in the emulator, I used the stopPropagation and preventDefault javascript functions to stop / cancel browsers that call their function keys (for example, F1 will start Firefox to open the help page), and the code works fine under Firefox and Chrome. But Opera does not work, Opera calls my function and launches the Opera help page. I am using the latest Opera 10.5 here. Can anyone help?
this code is in the FireFox JavaScript descriptor, and it is attached in the onkeydown HTML body:
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 uses ev.CancelBubble = true and ev.returnValue = false.
javascript opera keyboard-shortcuts
DonDon Jun 16 2018-10-06T00: 00Z
source share