This is another way:
During keydown, if it is k, and the input has no focus, then prevent the default behavior and focus on the text field.
$(document).keydown(function(event) {
if (event.which == 75 && !$('input').is(":focus")) {
event.preventDefault();
$('input').focus();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<input type="text">
Run codeHide result source
share