What event is used for autocomplete in jQuery – Education Career Blog

What is the correct event to use with autocomplete-type functionality? I’m doing something similar to autocomplete and tried using the "keypress" event, however, when I go to get the text out of the input that fired the even, it only has the text before the event was fired. Should I be using a different event, or perhaps just append the new character onto the existing text?


You want to use the keyup event to have the current value of the input.

Not the jQuery UI autocomplete does not do this, but for a different reason. It has a small delay between when they key is pressed and when a search occurs, so the value is populated by then. It’s actually using the keydown event for faster response to arrow keys and such.


At keypress, nothing has been put in. Use the keyup event, and you’ll have the value after the key was pressed.


better set an interval/timeout function on focus (remove it on blur) to:

  1. Check the number of char entered and change of content
  2. Perform the autocomplete query
  3. perfom auto completion

Leave a Comment