1

I have been using jquery hotkeys plugin from jeresig's hotkey. Shortcuts work fine when the document is in focus, but when the focus is in input fields, the shortcuts are not working. I have used $(document) or $(document).find('input') for binding. But these are not working either.

I have used this following code for making shortcut:

$(document).ready(function(){
        shortcutsInit(); 
});

function shortcutsInit(){
    $(document).bind('keydown', "shift+f2", function() {
        window.location.replace("/list");
        return false;
    });

    $(document).bind('keydown', "f3", function() {
        if($('#searchholder').length){
           $('#searchholder').focus();
        }
        console.log('f3 pressed');
        return false;
    });
}
nexuscreator
  • 835
  • 1
  • 9
  • 17

2 Answers2

0

try it :

$(document).ready(function(){
    $(document).on("keydown", function(e){
        if(e.shiftKey && (e.which || e.keyCode || e.charCode) == 113){
                window.location.replace("/list");
                return false;
        }
        if((e.which || e.keyCode || e.charCode) == 114){
            if($('#searchholder').length)
                $('#searchholder').focus();
            console.log('f3 pressed');
            return false;
        }
    });
});
0

Maybe these options are solving the problem:

$.hotkeys.options.filterInputAcceptingElements = false;
$.hotkeys.options.filterTextInputs = false;