I want to focus main search bar input after pressing “s”.
I have:
$("body").keypress(function(event) {
if(do_focus == 1 && event.which == 115)
{
$('#search-global-input').focus();
}
});
It’s working fine, but after pressing “s” I am in input, but with that “s” character.
How to get that “s” character away? 🙂
I tryied to load the string, cut it via substr, but without results..
Thank you
You should use de preventDefault method of Jquery to stop de real event and do what you want without creating conflicts… (pretty nice on elements to prevent redirections p.e)