title: jQuery - Binding key presses to function
body: <p>I know that this question has been asked and answered before, and I have found the answer already, but I had an issue for which I required some follow-up information, and as my rep is too low, I cannot comment on the relevant answer to ask for it!</p>
  
  <p>I am using sygmoral's answer for <a href="https://stackoverflow.com/questions/1402698/binding-arrow-keys-in-js-jquery">this post</a>, which should be the second answer down the page. I am using two functions to operate an image slider, one to slide left, and one to slide right. When clicking the on-screen buttons with the mouse cursor, each function operates perfectly, but when using sygmoral's function for key presses, only one of the left/right arrow keys triggers the function properly...</p>
  
  <p>The keypress function code goes like this:</p>
  
  <pre><code>    $(document).keydown(function(e){
          switch(e.which) {
              case 37:
              slideLeft();
  
              case 39:
              slideRight();
  
              default: return;                
          }
          e.preventDefault();
      });
  </code></pre>
  
  <p>case 39 works as it should. case 37 triggers the slideLeft() function, and the image slides left, but then immediately slides back to the right. If I swap cases 39 and 37, the opposite happens. Basically, only the second case will work properly.</p>
  
  <p>Can anyone offer me a suggestion as to why this might be?</p>