title: Javascript moving cursor on table that is editable move on save row
body: <p>I have Javascript to where a cursor moves on up, down, enter on a table. It works but I want to move the cursor left and right on the same row. How can I do that?</p>
  
  <p>I tried and it doesn't work:</p>
  
  <pre><code>else if (evt.keyCode == 39){
      event.preventDefault();
      var cellindex = $(this).index()
      var rowindex = $(this).parents('td').index() + 1
      $(this).parents('table').find('tr:eq('+rowindex+') td:eq('+cellindex+')').focus()
  }
  </code></pre>
  
  <p>This is the working code for up, down, enter.</p>
  
  <pre><code>jQuery(document).ready(function(){
      $('td').keydown(function(evt){
          if(evt.keyCode == 40){
              event.preventDefault();
              var cellindex = $(this).index()
              var rowindex = $(this).parents('tr').index() + 1
              $(this).parents('table').find('tr:eq('+rowindex+') td:eq('+cellindex+')').focus()
          }else if (evt.keyCode == 38){
                  event.preventDefault();
              var cellindex = $(this).index()
              var rowindex = $(this).parents('tr').index() - 1
              $(this).parents('table').find('tr:eq('+rowindex+') td:eq('+cellindex+')').focus()
          }
          else if (evt.keyCode == 13){
                  event.preventDefault();
              var cellindex = $(this).index()
              var rowindex = $(this).parents('tr').index() + 1
              $(this).parents('table').find('tr:eq('+rowindex+') td:eq('+cellindex+')').focus()
          }
      })
  });
  </code></pre>