Keydown event listener not working in Animate 2021
Copy link to clipboard
Copied
Hi all,
I have many programs that were working with keydown event listeners, but none of them work now in Adobe Animate 2021. Some are fully working games. Below is an example of the code used. This is a simple left key press to play a walk animation.
I tried to attach two different an Animate .fla file to this post but received an error message saying that the content type didn't match the file extension. Both open in Animate though.
import flash.events.KeyboardEvent;
stage.addEventListener(KeyboardEvent.KEY_DOWN, onkeydown);
function onkeydown(e:KeyboardEvent){
if(e.keyCode == 37){
ninjacat.gotoAndPlay("walk");
}
}
Copy link to clipboard
Copied
are you clicking your stage to interact with it before using the kb keys?
Copy link to clipboard
Copied
Yes I am. I have loaded the files into a an online Flash Emulator and have downloaded an old stand-alone Adobe Flash Player and the files work fine in both of these. My computer is a work one, managed by Education Qld, so I am going to get a student to test on their own device today (also Animate 2021) to eliminate this as the cause. I will update this post when done 🙂
Donna
Copy link to clipboard
Copied
it works for me in animate 2021
Copy link to clipboard
Copied
Solved - for some reason, the Show Redraw Regions in the settings wasn’t ticked. My laptop has been re-imaged three times in the last couple of months due to a number of problems so Animate has been re-installed each time. This should be a default setting, so have no idea why it wasn’t ticked? I’ve never been into the swf settings before either. Weird!
Copy link to clipboard
Copied
i don't think that's relevant, but i'm glad you no longer have a problem.

