title: Eliminate shake when using jQuery scrollTop
body: <p>I've got a function that scrolls down to the next section of an article when the down arrow on the keyboard is pressed and scrolls up when the up arrow is pressed.  Its working fine, however there is a slight "bounce" or "jitter" just before it scrolls.</p>
  
  <p>I was able to partial fix for this problem by having the function return false, however, returning false swallows the key down event, leaving me unable use my keyboard to interact with the browser.</p>
  
  <p>Any ideas on how to eliminate the "jitter" while at the same time freeing up my keyboard?</p>
  
  <pre><code>var $sections = $('.section');
  var curr = -1;
  
  $(document).keydown(function(e){
    prev = (curr &lt; 0)? $sections.length-1: curr-1;
    next = (curr &gt;= $sections.length-1)? -1: curr+1 ;
  
    switch (e.keyCode) {
      case 38:  // up key
        s = $sections.eq(prev).offset().top;
        curr = prev;
        break;
      case 40:  // down key
        s = $sections.eq(next).offset().top;
        curr = next;
        break;
      default:
        break;
    } 
  
    if (curr == -1 ){
      $('html, body').animate({scrollTop: 0}, 'slow');
    }
    else{
      $('html, body').animate({scrollTop: s}, 'slow');
    }
    return e;
  });
  </code></pre>