Keyboard Events

There was a comment by Muaad for help on how to capture Keyboard Events in AS 3.0. I figured instead of filling up a comment box I’d just go ahead and do a little post on it.

Keyboard Events and capturing them has been around for a long time. I’m going to assume Flash 4 days since I’d built a little animated typer in Flash 4 and can’t recall doing it Flash 3.

Like everything else in AS 3.0, you need to import the appropriate class(es);

For capturing Keyboard Events, you’ll need;

import flash.events.KeyboardEvent;
Add an eventListener to the stage for whatever you want to capture KEY_DOWN, KEY_UP, etc etc.
stage.addEventListener(KeyboardEvent.KEY_DOWN,checkKey);

List of Key Codes on Adobe

Source files

There you go, Muaad.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>