I have few inputs which you focus them using keycodes.
I am trying to: when focus on inputs, disable the keycodes function and when not focused, enable.
I tried this:
var hotkeys_function = false;
if (!hotkeys_function ){
$(document).keydown(function(e) {
if (e.keyCode == 71) {
$("#input1").fadeIn();
$("#input1").focus().select();
var hotkeys_function = true;
}
});
}
And this:
if ($("#input1").select()) {
var hotkeys_function = true;
}
but none seem to be working.
Not
$("#input1").select()but$("#input1").focus().In fact, no variables are needed, you can just check and return dynamically whether an input is focused or not.
Working example.