JQuery Prevent function keys by default (F3, F4, etc.)

I have this extremely simple example: http://jsfiddle.net/arhVd/1/

<form> <input type="text"> <input type="submit"> </form> $(function () { $(document).keydown(function(e) { e.preventDefault(); $('form').submit(); }); }); 

I want to make sure that when F4 is pressed, it does not perform the built-in browser function (in the case of F4, focus on the URL bar or, possibly, F3 showing the Find panel.) The form submission functionality still works, I just don’t want the functions browser interfere.

This is for an internal application in which function keys must function, has HotKeys in the application.

+1
jquery keyboard-events hotkeys
Nov 04 '10 at 18:26
source share
2 answers

This seems to work for F3 in IE8:

 $(document).keydown(function(event) { event.preventDefault(); if (event.keyCode == 114) { // F3 // Remap F3 to some other key that the browser doesn't care about event.originalEvent.keyCode = 0; } }; 

(based on http://www.fixya.com/support/t218276-disable_f3_function_key_from_intenet )

+5
Sep 16 2018-11-11T00:
source share

I do not believe that you can welcome the user's browser.

0
Nov 04 '10 at 18:32
source share



All Articles