javascript - keydown event not fired, why? -
In javascript, I place two keys below, and I think you are trying to do something like this: 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);
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
Post a Comment