Reputation:
Using keymaster library for defining and dispatching keyboard shortcuts, I defined shortcut key /
to focus input element.
key('/', function() {
$(".topbar input").focus();
});
The issue is that when the /
key is pressed, the input is focused with /
entered value. I want to get rid of that.
Upvotes: 1
Views: 217
Reputation: 18647
Try this.
key('/', function(event) {
$(".topbar input").focus();
event.preventDefault();
});
Upvotes: 3
Reputation: 717
It gets focused because you tell it to do so.
Remove this line:
$(".topbar input").focus();
Or give it a function so that you can do stuff when it gets focused
$(".topbar input").focus(function(){
});
Upvotes: 0