Featured Tutorials

web design articles, html, css, php, asp, include function,include in php,include in asp,including files,html include,asp include,php include,how to design websites,websites tutorial Building your website with includes

Building your website with includes

Using server side includes to design and code your web site allows you to keep your develo..

web design articles, css layouts, internet explorer, bug fixes,css fixes,transparent flash,flash lightbox,css help,css in IE,css problem ie,ie hacks,css hacks Internet Explorer CSS bug fixes

Internet Explorer CSS bug fixes

Fixes for some of the most common CSS bugs in internet Explorer..

graphics design,business cards,business card design,business card ideas,how to design, business card sizes,layouts Ideas for Business Card Layouts

Ideas for Business Card Layouts

Heres a few ideas for those struggling to come up with professional business card designs,..

flash,whiteboard,sketchpad,flash paint,ms paint,flash sketchpad,flash whiteboard,flash drawing,drawing effect Create your own Whiteboard / Sketchpad in Flash

Create your own Whiteboard / Sketchpad in Flash

Here's a very useful tutorial about how to create an ms paint style application within the..

photoshop,tutorial,photo editing,effects,Christmas Santa In Your Living Room

Santa In Your Living Room

This tutorial will show you how to put a person into an already existing photo (in this ca..

Featured Videos

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

Iam going to warn you that if you’re a web developer and you watc..

A great example of how the many Photoshop tools can be used to im..

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

This tutorial will teach you a more advanced way of creating more..

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