[Solved] Disable F1-F12 Key in jQuery


there are many ways to do this.

1) use a function like this

function DisableKeys() {
    var ar = new Array(122 , 123);
    $(document).keydown(function(e) {
        var key = e.which;
        if ($.inArray(key, ar) > -1) {
            e.preventDefault();
            return false; 
       }
        return true;
    });
}

2) example 2

$(document).keydown(function(e){
if(e.which === 122){
    return false;
if(e.which === 123){
    return false;
}

});

3) example 3

document.onkeydown = function(e) {
// keycode for F11 function
if (e.keyCode === 122) {
  return false;
}
// keycode for F12 function
if (e.keyCode === 123) {
// try to cancel the backspace
  return false;
}
};

1

solved Disable F1-F12 Key in jQuery