You can use the open and close autocomplete events to track whether the list of offers is open (by storing this information somewhere in the example below, in the "selectVisible" data ):
$( "#tags" ) .bind( "keydown", function( event ) { if ( event.keyCode === $.ui.keyCode.ENTER && !$(this).data("selectVisible") ) { // Your code } ... }) .autocomplete({ open: function() { $(this).data("selectVisible", true); }, close: function() { $(this).data("selectVisible", false); }, ... });
Working example in jsFiddle .
source share