javascript - keydown event not fired, why? -


In javascript, I place two keys below, and keydown is completely removed When I leave a key, funnel is removed. So far, so good. But I'm still putting a key down, so why not keydown has been removed? Do I need to be in my game? Is anything wrong with me? Is this the expected response? Is there any work or something else?

  window.addEventListener ("keydown", function (e) {console.log ('down');}, false); Window.addEventListener ('keyup', function (e) {console.log ('up');}, false);    

I think you are trying to do something like this:

  var below = false; Var up = false; Document.body.addEventListener ('keydown', function (e) {if (e.which === 40) {below = true;} if (e.j = === 38) {up = true;}}); Document.body.addEventListener ('keyup', function (e) {if (e.which === 40) {below = false;} if (e.j = === 38) {up = false;} // logic Here is one for the other, but not the other (below and above!) {Warning ('but not below!')}}});     / div> 

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -