Disable Opera softkey in javascript

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.

+2
javascript opera keyboard-shortcuts
Jun 16 2018-10-06T00:
source share
2 answers

To prevent the default keystroke action in Opera, you need to do this in the keypress event. Next from

+3
Jun 16
source share

I assume you are using the onkeydown event. This does not give you the necessary stuff in Opera. But it works fine in IE and Firefox. Therefore, you should use the onkeypress event in the opera. Therefore, you should have a separate code base for opera in your javascript, which can handle Opera function keys.

0
Jun 16 '10 at 5:32
source share



All Articles