How to disable slash and apostrophe keys from a quick search in Firefox using html / javascript?

I am making an HTML game that uses many keys on the keyboard. I have event handlers configured for $(document).keypress, but when I press the keys 'or /in Firefox, a “quick find” appears, interrupting the game and casting the focus away from the document.

How can I disable this? I have no problem in Chrome.

+5
source share
2 answers

If you use jquery, there is a "preventDefault ()" method in the Event object. This is a good solution due to compatibility in all major browsers.

$('selector').bind('event', function (event){
  event.preventDefault(); //this is what you want.
});

http://api.jquery.com/event.preventDefault/

+3

All Articles