How to Enable Enter Key in jQuery Autocomplete

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 *