PrestaCraft on Facebook

Please like our page on Facebook to get notifications about new tutorials :)


PrestaCraft

Tutorials

This “issue” happens when you type something in your search input field.

After seeing list of matching products (which appears under that field), you select something using your mouse and hit ‘Enter’.

Instead of going to the search results, the search engine acts like you’ve selected a product from a list.
Let me show you how to deal with it via simple trick.

Solution for this is quite simple. We need to catch a moment when ‘Enter’ key is pressed and prevent from executing any next javascript actions – and just send a form.

Edit: js/jquery/plugins/autocomplete/jquery.autocomplete.js

Find:

Add after:

In jQuery each key has its own code number. ‘Enter’ key is 13.

That’s why we are here catching if last pressed key code is belonging to 13. If so, we prevent any further action and submit a form programatically.

Add a comment

Leave a comment

Your email address will not be published.