title: How to do something if the user presses two keys in javascript
body: <p>So I wrote this script so that you can have keyboard shortcuts on your website, and I was wondering how to do multiple keys (ie instead of doing just the "left arrow" key, it would be the "ctrl + left arrow". Here's my current syntax:</p>
  
  <pre><code>var arrow = {
      left: 37,
      up: 38,
      right: 39,
      down: 40
  };
  
  function DoSomething() {}
  
  $(document).ready(function() { // requires jQuery
      $("body").keydown(function(event) {
          if(event.keyCode == arrow.left) {
              DoSomething();
          }
      }
  }
  </code></pre>
  
  <p>But what I would like to do is something like this:</p>
  
  <pre><code>var arrow = {
      left: 37,
      up: 38,
      right: 39,
      down: 40
  },
  
  ctrl = 17;
  
  function DoSomething() {}
  
  $(document).ready(function() { // requires jQuery
      $("body").keydown(function(event) {
          if(event.keyCode == ctrl &amp;&amp; arrow.left) {
              DoSomething();
          }
      }
  }
  </code></pre>