Below is a hack and basically it negates jQuery style and selection. Implemented a search callback and added a hack to remove the jQuery style and remove the hack when moving the mouse.
Demo
Note. I still do not have the opportunity to try again to enter the key.
$('#query').autocomplete({ source: [ "A", "AAA", "AAAAA", "AAAAAAAAA", "AAAAAAAAA", "AAAAAAAAAAA", "AAAAAAAAAAAAAA", "AAAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAAAAAAAA", "AAAAAAAAAAAAAAAAAAAAAAAA" ], search: function(event, ui) { $(document).on('mouseenter', '.ui-menu-item a', function(e) { //Remove jQuery styling and selection. $(this).removeClass('ui-state-hover'); this.id = ''; e.preventDefault(); }).one('mousemove', '.ui-menu-item a', function(e) { //implement mouse move once if moved inside the same li>a $(this).addClass('ui-state-hover'); this.id = 'ui-active-menuitem'; //unbind the mouse event so it works as normal $(document).on('mouseenter', '.ui-autocomplete', function(e) { $(document).off('mouseenter', '.ui-menu-item a'); }); }); } }); $('#query').keypress(function(ev) { if (ev.keyCode == 13) { alert('query: ' + $(this).val()); return (false); } });
source share