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

Hour 12. Responding to Events > Using Keyboard Events

Using Keyboard Events

Prior to the release of Netscape 4.0, JavaScript programs couldn't detect keyboard actions—just mouse actions. This made it difficult to create some types of programs in JavaScript. For example, games were difficult to play using Go Left and Go Right buttons.

Thankfully, JavaScript 1.2 and later can detect keyboard actions. The main event handler for this purpose is onKeyPress, which occurs when a key is pressed and released, or held down. As with mouse buttons, you can detect the down and up parts of the keypress with the onKeyDown and onKeyUp event handlers.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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