Keydown problem

Keydown problem

Hello
I'm having a strange delay between the input content and the val value... I mean: the val value is always one step behind of the real content of the input box... I don't know what am I doing wrong... Would you please give me a clue?
THANK YOU!!!



  1. $(document).on("keydown", "aside form input[name='search-shop']", function(){
  2. var val = $(this).val().toLowerCase();
  3. if(val.length > 1){
  4. $(".galleryFront h2:contains('"+val+"')").closest('.gallery').fadeIn("slow").siblings('.gallery').hide();
  5. }else{
  6. $(".gallery").fadeIn("slow");
  7. }
  8. countResults();
  9. });