Featured Tutorials

flash,actionscript,script,scripting,key press,key pressing,key buttons,key listener,keyboard input,on release,detecting keyboard,key press in flash Flash Detect Keyboard Input with Key Listeners

Flash Detect Keyboard Input with Key Listeners

Learn how to detect keyboard input in flash for applications and game controls using a bit..

traffic,social bookmarking sites,social bookmarking traffic,stumble upon tips,submitting to stumble upon,submitting to digg,digg traffic,stumble upon traffic,traffic to my website,getting traffic,getting social traffic,best social sites,best link sites How to Get Traffic from Social Bookmarking Sites

How to Get Traffic from Social Bookmarking Sites

Here's a great list of blog posts that have carried out research into some of the biggest ..

css tricks,css hacks,css tips,css forms,form validation,stopping spam,stop form spam,email spam,email form spam,fight spam,stop form spam,form spam Fight Email Form Spam with some CSS Trickery

Fight Email Form Spam with some CSS Trickery

Heres a great little post on how to setup your online email form validation to stop robot ..

flash gallery,rotating gallery,dynamic flash,dynamic gallery,flash based gallery,flash image changing,change images Dynamic Rotating Gallery in Flash

Dynamic Rotating Gallery in Flash

This tutorial will teach you how to create a dynamic rotating gallery within flash for sho..

drag,drop,jigsaw,puzzle,flash,drag drop,drag in flash,drag drop flash,flash jigsaw,flash puzzle,flash game,actionscript drag,draggable button   Drag and Drop Jigsaw Puzzle in Flash

Drag and Drop Jigsaw Puzzle in Flash

This flash tutorial will teach you how to create a drag and drop jigsaw puzzle, by creatin..

Featured Videos

Informative but scary video about the history of Google, where it..

This tutorial will teach you some of the basics of the third part..

This video will open your eyes to the strange phenomenon of Traga..

Heres a great spoof video for the technically challenged develope..

This detailed tutorial will show you how to create a realistic ch..

Flash Detect Keyboard Input with Key Listeners

Heres another helpful bit of flash actionscript code to help you on your way with developing dynamic flash content.

 

Key Listeners

Key Listeners allow you to record the input of keys from the keyboard in flash and allow you to peform actions with keys

First you need to setup your key listener as a function as follows:


KeyListener = new Object();
KeyListener.onKeyDown = function() {
if (Key.getAscii() == 13) { // Code for ENTER key
gotoAndPlay(25);
} else if (Key.getAscii() == 8) { // Code for BACKSPACE key
gotoAndPlay(35);
}
}

 

Then either after the function or on another frame where you want the key listender to start simply add this code:


Key.addListener(KeyListener);

 

Detecting if "Any Key" is pressed


this.createEmptyMovieClip("_keyListener",1);
Key.addListener(_keyListener);
_keyListener.onKeyDown=function(){
play();
}

 

Useful Key ASCII/ALT Codes

ENTER

13

BACKSPACE

8

SHIFT

16

CTRL

17

ALT

18

0

48

1

49

2

50

3

51

4

52

5

53

6

54

7

55

8

56

9

57

Arrow Keys (left)

37

Arrow Keys (up)

38

Arrow Keys (right)

39

Arrow Keys (down)

40



More Flash...

Other Content...

 Subscribe to our feed

Send to a friend