Jquery shortcuts not working on IE

Hi I am using jQuery.hotkeys.js to connect a keypad. All other shortcuts work fine, but f1 does not work as expected in IE. Pressing the "f1" key associates a shortcut, but is called more than once, and also opens a help window.

The code is as follows:

 $(document).bind('keydown', 'f1', function (evt) {
        evt.preventDefault();
        evt.stopPropagation();
        alert('some message');
         window.event.keyCode = 0;
        return false;
}); 

please give me an idea for this.

thank

Munish

+3
source share
2 answers

In Internet Explorer, a key F1cannot be revoked using the keydown handler. You can attach to onhelp:

window.onhelp = function () {
    return false;
} 

The problem with firing doubles is probably an error in the plugin code, if it occurs only in Internet Explorer, you can bypass it using the event onhelp:

if ("onhelp" in window) // IE
    window.onhelp = function() {
        alert("some message");
        return false;
    }
else // Others
    $(document).bind('keydown', 'f1', function(evt) {
        alert('some message');
        return false;
    });
+3

-, F1? , ( -).

, preventDefault(), stopPropagation() return false.

+1

Source: https://habr.com/ru/post/1774931/


All Articles