I would use something like: Demo
$(this).keyup(function(e) {
if(~['input', 'textarea'].indexOf(e.target.tagName.toLowerCase())) return;
if(e.which == 37) {
document.location = $("#prev_button").attr('href');
}else if(e.which == 39) {
document.location = $("#next_button").attr('href');
}
});
This way you can exclude all <input>
and <textarea>
elements.
IMO, excluding just #searchbox
isn't a great solution because in the future you may change its id
or include other text fields, but forget you must reflect changes in the exclusion script.