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

Chapter 9. Handling Events > Getting Specific Key Values

Getting Specific Key Values

As you can imagine, handling the KeyDown, KeyUp, and KeyPress events by themselves won't get you very far. What you'll be interested in most of the time is knowing exactly which key the user pressed. For example, if you have a form field that must contain only numbers, you can watch for non-numeric keys being pressed and cancel them.

Figuring out the exact key pressed requires the use of the Event object, which JavaScript uses to store data about the current event. For example, if JavaScript detects one of the keyboard events, it uses the Event object to store a code that specifies which key was pressed.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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