Ko9
Ko9

Reputation: 199

Keyboard input using ActionScript 3

I am learning how to use Flash using CS4, and focusing mainly on ActionScript3 (since I come from a coding background and not a designer background).

I want to respond to the user pressing keys on the keyboard.

I have used the official example source at the Flash reference site and followed the CS4 instructions for classes. However, all it responds to is special keys like ctrl and shift, for these keys it works fine. For keys like a,b,c there is no response whatsoever. Am I doing something wrong? Is there some setting I need to change? Maybe I need to change something outside my ActionScript (like a project setting maybe). Any help would be greatly appreciated.

Upvotes: 0

Views: 1695

Answers (3)

Bill
Bill

Reputation: 305

The up and down handlers trap different kinds of keys:

KeyboardEvent.KEY_DOWN gets keyslike backspace and delete, while KeyboardEvent.KEY_UP gets the usual a-z suspects.

Upvotes: 0

Theo.T
Theo.T

Reputation: 9267

A quite usual problem is that the Flash IDE shortcut keys won't respond (as they are used by the IDE). Make sure you also test your movie in a browser or in the standalone player.

Upvotes: 2

Tyler Egeto
Tyler Egeto

Reputation: 5495

Are you running it in full screen mode? You can't hear those keys if you are. (Security restriction)

Upvotes: 1

Related Questions