Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes please! This was the first thing I noticed, maybe my netbook is too slow but I do a lot of coding on the little thing.

The way I solved this in a similar auto-complete app was using a setTimeOut to prevent updating or requesting data unless no key had been pressed in the last 0.2 seconds or so:

    var updateId = 0;
    function searchKeypress(e) {
      if ((e || window.event).keyCode == 13) {
        updateCookie(radioStations.selected);
        document.location = radioStations.selected.links[0].url;
      }
      clearTimeout(updateId);
      updateId = setTimeout(searchUpdate, 200);
    }
Disclaimer: this piece of code is about 4 years old and as you can see it doesn't even use jQuery, but I trust it demonstrates the principle well enough.


Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: