Home > Element Reference : Event

Contents

### Event

The event object that is available in all event handlers. you can access it through the object event and it contains properties that provide information about the event.

#### Properties and Methods:

altKey

Set to true if the alt key was pressed to invoke the event handler.

bubbles

Set to true if the event is going to bubble up the element hierarchy. You can cancel this by calling the preventBubble method.

button

Set to the mouse button that was pressed to invoke a mouse event.

cancelable

Set to true if the event can be cancelled.

charCode

Gets and sets the value of the charcode attribute.

clientX

The horizontal position of a mouse event on the window.

clientY

The vertical position of a mouse event on the window.

ctrlKey

Set to true if the control key was pressed to invoke the event handler.

currentTarget

This will be set to the element that is currently receiving the event, which will vary as the bubbles through elements.

detail

Contains additional information about the event. For mouse click events, this value will be set to the number of clicks that occured. Thus, the value will be 2 if the user double-clicks.

eventPhase
isChar

Set to true if the event is a key or text event.

keyCode

Gets and sets the value of the keycode attribute.

layerX
layerY
metaKey

Set to true if the meta key was pressed to invoke the event handler.

originalTarget

The original target of the event. This is used for elements that have bindings to get the element inside the binding that actually received the event.

pageX

The horizontal position on the document page when the event occured. This is not the same as the window position because the page may be larger than the window.

pageY

The vertical position on the document page when the event occured. This is not the same as the window position because the page may be larger than the window.

preventBubble ( )

Call this function to prevent the bubbling of the event.

preventCapture ( )

Call this function to prevent the capturing of the event.

rangeOffset
rangeParent
relatedTarget
screenX

The horizontal position on the screen of a mouse event.

screenY

The vertical position on the screen of a mouse event.

shiftKey

Set to true if the shift key was pressed to invoke the event handler.

stopPropagation

Stops the event.

target

The target event. For mouse events this will be set to the element that was clicked on. For keyboard events this will be set to the element that has the focus. The target property is useful if a parent element is capturing events, so that you can tell which child element the event occured to.

timeStamp

The time the event occured as a number.

type

The event type such as click, keydown or focus.

view

The view (window) the event was passed to.

which

Copyright (C) 1999 - 2002 XULPlanet.com