title: Using arrows-keys to navigate
body: <p>I am wondering if there was a possibility to navigate with arrow keys through a table I created with JS(using jQuery)? I mean jumping from cell to cell...The script is for Greasemonkey.</p>
  <p>The alert, however, works. I just got no idea how to make it well-functioning.</p>
  <pre><code>$(document).keydown(function(e){
      if (e.keyCode == 37) { 
         alert( &quot;left pressed &quot; );
         return false;
      }
      if (e.keyCode == 38) { 
         alert( &quot;up pressed &quot; );
         return false;
      }
      if (e.keyCode == 39) { 
         alert( &quot;right pressed &quot; );
         return false;
      }
      if (e.keyCode == 40) { 
         alert( &quot;down pressed &quot; );
         return false;
      }
  });
  ;</pre></code>
  <p>Any hint or whatever is much appreciated.
  Thanks in advance,
  Faili</p>
  <p><strong>Update</strong></p>
  <p>It seems like I explained myself wrong. Give me another try:
  <a href="https://jsfiddle.net/s3YDC/" rel="nofollow noreferrer">Demo</a></p>
  <p>This one may give you an idea of what I wanted. After selecting one input-field a navigation with arrow keys is possible.
  My problem is that I just can't realise it via GM and jQuery. Any idea?</p>
  <p>Thanks again for your time and effort.</p>
  <p><strong>Finally</strong> it was like:</p>
  <pre><code>
  function myTest_analysis1(e,leftkey,up,right,down){
      myTest(e,'','','field_analysis2','field_communication1')
  
  function myTest(e,leftkey,up,right,down)
  {
    if (!e) e=window.event;
    var selectArrowKey;
    switch(e.keyCode)
    {
    case 37:
      // Key left.
      selectArrowKey = leftkey;
      break;
    case 38:
      // Key up.
      selectArrowKey = up;
      break;
    case 39:
      // Key right.
      selectArrowKey = right;
      break;
    case 40:
      // Key down.
      selectArrowKey = down;
      break;
    }
    if (!selectArrowKey) return;  
    var controls = window.document.getElementById(selectArrowKey);
    if (!controls) return;
    controls.focus();
  }
  }
   $('#field_analysis1').keydown (myTest_analysis1);
  </pre></code>
  <p>That's how it worked out for me. I bet there is a smarter solution, but I couldn't figure it out right now.</p>
  <p>Thank you sooo much for your time and effort.</p>