title: Keyboard navigation: how to go to the next and previous element with arrow keys?
body: <p>I am trying to build a site with keyboard navigation. I want the user to be able to navigate through a menu of five or six pages using the left and right arrows.
  No matter on which page is the user, I want him/her to go back/forward in the menu when the left/right arrow is pressed.  </p>
  
  <p>Let's say the horizontal menu is built this way :<br>
  [Home / Random page / Some page / Another page / And so on]  </p>
  
  <p>Apparently it is not working. Here is what I have so far : </p>
  
  <pre><code>document.onkeyup = KeyCheck;       
  
  var pages = ["index.php", "random-page.php", "some-page.php", "another-page.php", "and-so-on.php"];
  
  function leftarrowpressed() {
      location.href = pages[0]-1;
  }
  
  function rightarrowpressed() {
      location.href = pages[0]+1;
      }
  } 
  
  function KeyCheck(e)
      {
         var KeyID = (window.event) ? event.keyCode : e.keyCode;
  
         switch(KeyID)
         {
  
   // left arrow key
           case 37:
           leftarrowpressed()    
            break;
  
  //  right arrow key
            case 39:
            rightarrowpressed() 
            break;
  
         }
      }
  </code></pre>
  
  <p>Thank you all for your help.</p>