I need to override the autofill focus event using a custom action and do something depending on whether the user selected from the list using the keyboard, not the mouse. To do this, I check the originalEvent.type file in the event object, which should contain the type of action to be performed (keydown, keyup, mouseenter, etc.).
However, the originalEvent object seems undefined, and I cannot understand why. It works fine in a real focus event in the autocomplete code, but not when I redefine this event inside an autocomplete object.
See my code below. I would appreciate any help on this, as it makes me bananas.
$( "#tags" ).autocomplete({ source: availableTags, focus: function(event, ui) { //Check whether focus was triggered by a mouse or keyboard event if ( /^key/.test(event.originalEvent.type) ) { //Do something here } return false; } });
source share