Skip to main content
January 2, 2010
Question

Flash Key Pressed Function

  • January 2, 2010
  • 1 reply
  • 468 views

Hi, i want to make flash to go to the next frame no matter of that what letter keyboard key you press. Is that possible? But i need only letter keys not others like Tab, Enter, Backspace or Space... Thanks for your help.

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
January 2, 2010

Key codes generally are grouped into sets, starting at one value thru another.  So you can use a set of conditionals to test if the key code is within the range of the letter keys.  Here's a link to a chart showing the key codes for Flash...

http://people.uncw.edu/tompkinsj/112/FlashActionScript/keyCodes.htm

Here is an example in AS2.  Be sure to disable keyboard shortcuts in the player when testing locally.

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
var keyPressed= Key.getCode();
    if (keyPressed > 64 && keyPressed < 91) {
        trace("You're pressing a letter key");
    }
};
Key.addListener(keyListener);

January 3, 2010

10x

Ned Murphy
Legend
January 3, 2010

You're welcome