Skip to content
Home » Web » jQuery » jQuery Autocomplete Enter Key

jQuery Autocomplete Enter Key

Assuming that your autocomplete element is identified as #search in HTML. Here is the code snippet of enabling Enter key in your customized jQuery file:

...
$("#search").autocomplete().keydown(function(e){
    if (e.keyCode === 13){
        $("#search").trigger('submit');
    }
});
...

The above code is independent from original $("#search").autocomplete() code block.

Leave a Reply

Your email address will not be published. Required fields are marked *