Reading from keyboard

How do I read a key from the keyboard and use that key to generate an animation? For example, I type 1 on the keyboard upon presssing the 1 it will trigger an animation?

try this:

createEmptyMovieClip("lstnr", ++depth);
Key.addListener(lstnr);
lstnr.onKeyDown = function() {
	if (Key.isDown(49)) {
		/*
		code goes here
		*/
	}
};

[edit]

Key object key codes:

A: 65
B: 66
C: 67
D: 68
E: 69
F: 70
G: 71
H: 72
I: 73
J: 74
K: 75
L: 76
M: 77
N: 78
O: 79
P: 80
Q: 81
R: 82
S: 83
T: 84
U: 85
V: 86
W: 87
X: 88
Y: 89
Z: 90
0: 48
1: 49
2: 50
3: 51
4: 52
5: 53
6: 54
7: 55
8: 56
9: 57

[AS]
on (keypress “1”){
_root.movieClip.gotoAndPlay(“whatever”);
}
[/AS]

i’m sorry i didn’t get the correct message through. what i meant was if a user type in number 1, the movie will display the binary number of 1. the key is i will not know what the user is going to type. so if the user type in number 8, it will display the binary of 8

this.onKeyDown = function() {
	var num = parseInt(String.fromCharCode(Key.getCode()));
	var bin = parseInt(num.toString(2));
	trace(bin);
};
Key.addListener(this);

i just realized that it doesn’t work if you use the numeric keypad…

this.onKeyDown = function() {
	var code = Key.getCode()>=96 ? Key.getCode()-48 : Key.getCode();
	var num = parseInt(String.fromCharCode(code));
	var bin = parseInt(num.toString(2));
	trace(bin);
};
Key.addListener(this);

problem solved. :stuck_out_tongue:

i now can get the binary display out liaoz but the problem is i want the binary display in the particular place where i want to dispaly but not in the output column. so now what can i do to do that? sorry. thanks