title: Prevent window scroll jquery
body: <p>I'm developing a select menu replacement in jquery.<br>
  First I've to make the new select menu focusable by just adding <code>tabindex="0"</code> to the container.<br>
  Then, I disable focus on the original select menu and give focus to the new one.
  When the new one is focused and you press the up and down arrows the options change accordingly but there's a big problem. As you press the arrows the body moves too.<br>
  I tried all these solutions so far with no luck:</p>
  
  <pre><code>$(window).unbind('scroll');
  $(document).unbind('scroll');
  $('body').unbind('scroll');
  $(window).unbind('keydown');
  $(document).unbind('keydown');
  </code></pre>
  
  <p>Check the code here <a href="http://pastebin.com/pVNMqyui" rel="nofollow noreferrer">http://pastebin.com/pVNMqyui</a>
  This code is from the development version of Ideal Forms <a href="http://code.google.com/p/idealforms" rel="nofollow noreferrer">http://code.google.com/p/idealforms</a> that I'm about to release soon, with keyboard support.</p>
  
  <p>Any ideas why this is not working?</p>
  
  <p><strong>EDIT:</strong> Solved!</p>
  
  <p>Found the answer on this post <a href="https://stackoverflow.com/questions/1169625/jquery-link-tag-enable-disable">jquery link tag enable disable</a></p>
  
  <pre><code>var disableScroll = function(e){
      if (e.keyCode === 40 || e.keyCode === 38) {
          e.preventDefault();
          return false;
      }
  };
  // And then...
  events.focus: function(){ $(window).on('keydown', disableScroll); }
  events.blur: function(){ $(window).off('keydown', disableScroll); }
  </code></pre>
  
  <p>It works!</p>