• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Hour 9. Getting Input from the User > Detecting Keypresses

Detecting Keypresses

There are three ways to detect a single keypress on the keyboard. The first uses buttons. The second uses the Key object. A third method is new to Flash MX and uses listeners.

Detecting Key Presses Through Buttons

Strangely enough, you can use buttons to detect keyboard key presses. All you need to do is use a special on handler in the script attached to the button. For instance, here is a handler that looks for the “a” key to be pressed:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint