title: Passing Parameters to KeyDown
body: <p>How can you pass parameters into the keydown method from jquery because whenever I use a variable defined elsewhere it returns undefined. I assume its because the #target is window and therefore its not in the scope but even then I have trouble getting it to compare the key.which() with an outside parameter and then assigning it to another property.</p>
  
  <p>Example:</p>
  
  <pre><code>var a = 38;
  var b = 0;
  $(document).keydown(function(e){
    var key = e.which;
    if (a==key)
      b=key;
  });
  console.log(a+""+b);
  </code></pre>
  
  <p>Whenever I try to do something along the same lines it returns 38 0 which I interpreted as it not being in the scope and being undefined (also because if I log b it prints undefined in the keydown func)? How could I pass in a?</p>