title: JavaScript - Uncaught ReferenceError: KEY is not defined
body: <p>I'm reading a book on creating games with HTML5 and have problem with this code.no matter what i do i can't make it work.i removed descriptions from code so it's less to read.and all the code here is copied from book.</p>
  
  <p>I get the error  " Uncaught ReferenceError: KEY is not defined " for UP KEY on line 23.and if i remove that block of code entirely i get the same error for DOWN KEY so what do you think is the problem?</p>
  
  <pre><code>var pingpong = {}
  pingpong.pressedKeys = [];
  $(function(){
  
  pingpong.timer = setInterval(gameloop,30);
  
  $(document).keydown(function(e){
  pingpong.pressedKeys[e.which] = true;
  });
  $(document).keyup(function(e){
  pingpong.pressedKeys[e.which] = false;
  });
  });
  
  
  
  function gameloop() {
  movePaddles();
  }
  function movePaddles() {
  
  pressed.
  if (pingpong.pressedKeys[KEY.UP]) {
  
  var top = parseInt($("#paddleB").css("top"));
  $("#paddleB").css("top",top-5);
  }
  if (pingpong.pressedKeys[KEY.DOWN]) { 
  
  var top = parseInt($("#paddleB").css("top"));
  $("#paddleB").css("top",top+5);
  }
  
  
  if (pingpong.pressedKeys[KEY.W]) { 
  
  var top = parseInt($("#paddleA").css("top"));
  $("#paddleA").css("top",top-5);
  }
  if (pingpong.pressedKeys[KEY.S]) { 
  
  var top = parseInt($("#paddleA").css("top"));
  $("#paddleA").css("top",top+5);
  }
  }
  </code></pre>