JavaScripture
Contribute via GitHub Feedback

JavaScript MouseEvent : UIEvent

MouseEvent contains information describing the current event generated by a mouse action such as move or click.

Constructors

new MouseEvent(type : String, [eventInit : Object]) : MouseEvent
eventInit : {
bubblesBoolean
cancelableBoolean
viewWindow
detailNumber
screenXNumber
screenYNumber
clientXNumber
clientYNumber
ctrlKeyBoolean
shiftKeyBoolean
altKeyBoolean
metaKeyBoolean
buttonNumber
buttonsNumber
relatedTargetElement
}

Creates a new MouseEvent of the specified type and initial properties.

Instance Properties

altKey : Boolean  

true if the Alt key (Option on Mac) on the keyboard was pressed at the time the event was generated. See also getModifierState().

Example:

Run

Results:

 

button : Number  

The mouse button that generated this event. 0 is the primary (left) button. 1 is the middle button. 2 is the secondary (right) button. See also buttons.

Example:

Run

Results:

 

buttons : Number  

The bitwise combinations of mouse buttons pressed. 1 is the primary (left) button. 2 is the secondary (right) button. 4 is the middle button. Will be 0 when no buttons are pressed. See also button.

clientX : Number  

The x position of the pointer relative to the viewport at the time the event fired. See also clientY, screenX, and screenY.

Example:

Run

Results:

 

clientY : Number  

The y position of the pointer relative to the viewport at the time the event fired. See also clientX, screenX, and screenY.

Example:

Run

Results:

 

ctrlKey : Boolean  

true if the Control key on the keyboard was pressed at the time the event was generated. See also getModifierState().

Example:

Run

Results:

 

metaKey : Boolean  

true if the keyboard's meta (Command on Mac, not available on Windows) key was pressed at the time the event was generated. See also getModifierState().

Example:

Run

Results:

 

relatedTarget : Element  

Only applies to focusin, focusout, mouseenter, mouseleave, mouseout, mouseover, dragenter, and dragexit events. It is the element that the receives the opposite event pair for this event. For example, the relatedTarget of a mouseenter is the element that will receive the mouseleave event.

screenX : Number  

The x position of the pointer on the screen at the time the event fired. See also screenY, clientX, and clientY.

Example:

Run

Results:

 

screenY : Number  

The y position of the pointer on the screen at the time the event fired. See also screenX, clientX, and clientY.

Example:

Run

Results:

 

shiftKey : Boolean  

true if the Shift key on the keyboard was pressed at the time the event was generated. See also getModifierState().

Example:

Run

Results:

 

Instance Methods

getModifierState(modifierKey : String) : Boolean

Returns true if the the modifierKey is pressed or active. modifierKey must be one of 'Alt', 'AltGraph', 'CapsLock', 'Control', 'Fn', 'Meta', 'NumLock', 'ScrollLock', 'Shift', 'SymbolLock', or 'OS'.