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

9. Managing Events > 9.7. Determining Which Mouse Button Was Pressed

Determining Which Mouse Button Was Pressed

NN 6, IE 4

Problem

You want your event handler function to read which mouse button or button combination was used for a click-related mouse event.

Solution

Both the IE and W3C DOM event models agree that the button property of the event object is the one that holds information about the button or buttons used to generate a mousedown event (button values don’t always come with mouseup or click events). Unfortunately, this is where the similarity ends.

Some of the integer values associated with the button property differ between the two event models. But they do agree that a value of 2 means that the right (nondominant) mouse button was used for the event. Here is a template for an event handler function that branches into separate processing paths for the right button and all other buttons:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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