Try preventing the default behaviour of the enter keypress:
$("#query").keypress(function(e) {
if(e.which == 13) {
e.preventDefault();
alert('You pressed enter!');
redditsearch();
}
});
Without this, if your input is within a form, the form will be submitted along with your search function called. The preventDefault stops the default form submission behaviour.