title: Using up and down arrow for table with vertical scroll
body: <p>I create fiddle:</p>
  
  <p><a href="http://jsfiddle.net/marko4286/7TmJc/" rel="nofollow">http://jsfiddle.net/marko4286/7TmJc/</a></p>
  
  <pre><code>function arrowUp() {
      var activeTableRow = $('.table tbody tr.active').removeClass('active').first();
      if (activeTableRow.length) {
          activeTableRow.prev().addClass('active');
      } else {
          $('.table tbody').children().last().addClass('active');
      }
  };
  function arrowDown() {
      var activeTableRow = $('.table tbody tr.active').removeClass('active').first();
      if (activeTableRow.length) {
          activeTableRow.next().addClass('active');
      } else {
          $('.table tbody').children().first().addClass('active');
      }
  };
  
  
  $(window).keydown(function (key) {
      if (key.keyCode == 38) {
          arrowUp();
      }
      if (key.keyCode == 40) {
          arrowDown();
      }
  });
  </code></pre>
  
  <p>The problem is when I use the up/down arrow keys, and when I have a vertical scroll. When it comes to an end automatically returns to the first row.</p>
  
  <p>I would like to stop selecting up when I'm on the first row and selecting rows down when I'm on the last row. </p>
  
  <p>Also, the problem is that I have a vertical scrolling, selecting rows via the arrow is farewell as it should, because it automatically scrolls the div (example of how it should work selecting a row when table or div has vertical scroll <a href="http://dhtmlx.com/docs/products/dhtmlxGrid" rel="nofollow">http://dhtmlx.com/docs/products/dhtmlxGrid</a> /)</p>