JavaScripture
Contribute via GitHub Feedback

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 : {
bubbles :Boolean
cancelable :Boolean
view :Window
detail :Number
screenX :Number
screenY :Number
clientX :Number
clientY :Number
ctrlKey :Boolean
shiftKey :Boolean
altKey :Boolean
metaKey :Boolean
button :Number
buttons :Number
relatedTarget :Element
}

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. 8 is the back mouse button. 16 is the forward mouse 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. This is the same as x. See the corresponding clientY and alternative coordinates offsetX, pageX, and screenX.

Example:

Run

Results:

 

clientY : Number  

The y position of the pointer relative to the viewport at the time the event fired. This is the same as y. See the corresponding clientX and alternative coordinates offsetY, pageY, 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:

 

movementX : Number  

The change in x position of the pointer since the last time the mouse move event fired. See the corresponding movementY and element.requestPointerLock().

Example:

Run

Results:

 

movementY : Number  

The change in y position of the pointer since the last time the mouse move event fired. See the corresponding movementX and element.requestPointerLock().

Example:

Run

Results:

 

offsetX : Number  

The x position of the pointer relative to this the time the event fired. See the corresponding offsetY and alternative coordinates x, clientX, pageX, and screenX.

Example:

Run

Results:

 

offsetY : Number  

The y position of the pointer relative to this at the time the event fired. See the corresponding offsetX and alternative coordinates y, clientY, pageY, and screenY.

Example:

Run

Results:

 

pageX : Number  

The x position of the pointer relative to the page at the time the event fired. Same as this.clientX + window.scrollX. See the corresponding pageY and alternative coordinates x, clientX, offsetX, and screenX.

Example:

Run

Results:

 

pageY : Number  

The y position of the pointer relative to the page at the time the event fired. Same as this.clientY + window.scrollY. See the corresponding pageX and alternative coordinates y, clientY, offsetY, and screenY.

Example:

Run

Results:

 

relatedTarget : Element  

Only applies to focusin, focusout, mouseenter, mouseleave, mouseout, mouseover, dragenter, and dragexit events. It is the element that 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 the corresponding screenY and alternative coordinates x, clientX, offsetX, and pageX.

Example:

Run

Results:

 

screenY : Number  

The y position of the pointer on the screen at the time the event fired. See the corresponding screenX and alternative coordinates y, clientY, offsetY, and pageY.

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:

 

x : Number  

The x position of the pointer relative to the viewport at the time the event fired. This is the same as clientX. See the corresponding y and alternative coordinates offsetX, pageX, and screenX.

Example:

Run

Results:

 

y : Number  

The y position of the pointer relative to the viewport at the time the event fired. This is the same as clientY. See the corresponding x and alternative coordinates offsetY, pageY, and screenY.

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', or 'SymbolLock'.