title: Javascript Variable Increase
body: <p>I am a noob to javascript and and programming really and I just want to know what I am doing wrong. Im sure this is a really simple question but I have no idea why this isn't working. According to research online I'm doing everything correctly.</p>
  
  <pre><code>var varname  = 0;
  $(document).keydown(function(e) {
      if(e.which == 74) {
          varname++;
          console.log(varname);
      }
  }
  </code></pre>
  
  <p>Everytime I press "j" I want to increase my variable, but console log shows a consistent 1 and doesn't go any higher. What can I do Thanks for the help. The key press event works fine, the number just wont increase upon the keypress. Thanks again</p>