Featured Tutorials

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..

vector photos,vector art,pen tool,photoshop,photoshop pen tool,pen tool illustration,vector pen tool,vector illustration,vector in photoshop How to Vector Illustrate a Photo with the Pen Tool in Photoshop

How to Vector Illustrate a Photo with the Pen Tool in Photoshop

This very detailed tutorial will show you some of the techniques you will need for transfo..

flash tutorials, fireworks, particle effects, flash animation,fireworks in flash,creating fireworks,fireworks movie,fireworks display,how to create fireworks,flash fireworks tutorial,fireworks tutorial Flash Firework Frenzy

Flash Firework Frenzy

Create a realistic particle based firework display using Flash. This technique was once us..

photoshop tutorials, gradient filter, website layouts,gradient mapping,gradient tool,gradient in photoshop,photoshop gradients,how to gradients,gradient colours,gradient colors,blending tools Become a Gradient Junkie

Become a Gradient Junkie

Gradients are like gold when it comes to creating clean, sleek designs, This article hopes..

web design guide, how to, website design, tips, advice,web design tutorial,design tutorial,websites,learn html,learn css,css tips,html tips,seo tips Web Development Guide

Web Development Guide

A large selection of expert tips and advice to help you design and market the perfect web ..

Featured Videos

This detailed tutorial will teach you how to create a realistic l..

This detailed 3D Studio Max tutorial will teach you how to animat..

This is a very good tutorial for beginners who want to learn how ..

If your learning Flash this is a must know, as it will help you t..

Sorenson Squeeze is a great piece fo software that has saved my a..

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