M
M
MaxFreedom2017-04-03 16:22:48
JavaScript
MaxFreedom, 2017-04-03 16:22:48

How to make addEventListener work fine in Microsoft Edge?

Hello!
Guys, tell me why addEventListener works fine in all browsers except Microsoft Edge. The problem is in this code:

document.addEventListener("keydown", function(event){
        key[event.keyCode] = true;
        if(32 in key ){
          .... my code ....
        }
      }, false);

That is, I receive an event when a space is pressed, in my case it is a bird jump up (Flappy Bird on HTML + canvas). On the "keyup" event, the function to clear the key array is triggered and the bird falls down. It works fine in all browsers, but "keyup" does not always work in EDGE, when you release the spacebar, the bird flies further and only after a while falls. In other words, there is a big pause between events, but I repeat, this is only in EDGE. Maybe someone knows how to fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MaxFreedom, 2017-04-03
@RomanticOS

As usual, I found the answer myself! Yes, in IE this function works fine, but the error is in EDGE itself... everything is as usual, technology goes one way, and MicroSoft goes the other way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question