I am creating an interactive product in Adobe Animate CC 2017 using the HTML5 Canvas.
I am trying to detect a keydown
and keyup
event on the arrow keys so that I can animate a character walking when the user presses the arrow key. I need to listen for keyup
so that the character stops walking when they let go of the key.
I have the following code, but the keyup
event refuses to fire consistently. It fires maybe on every 10 arrow keys pressed. Is this a bug in Adobe Animate CC? When I put the same code into a plain HTML file, it works perfectly.
window.addEventListener("keydown", function(e){
console.log("Down: " + e.keyCode);
});
window.addEventListener("keyup", function(e){
console.log("Up: " + e.keyCode);
});
Only thing that comes to my mind is the script you have is on a keyframe of a timeline that is not paused causing it to be inconsistent. If you think this is possible put in the following with your key function code and open the console in dev tools to see if it fires multiple times.