WD-DOM-Level-2-19990719


5. Document Object Model Events

Editors
Tom Pixley, Netscape Communications Corporation
Chris Wilson, Microsoft Corporation

Table of contents


5.1. Overview of the DOM Level 2 Event Model

The DOM Level 2 Event Model is designed with two main goals. The first goal is the design of a generic event system which allows registration of event handlers, describes event flow through a tree structure, and provides basic contextual information for each event. Additionally, the specification will attempt to provide standard sets of events for user interface control and document mutation notifications, including defined contextual information for each of these event sets.

The second goal of the event model is to provide a common subset of the current event systems used within Microsoft Internet Explorer 4.0 and Netscape Navigator 4.0. This is intended to foster interoperability of existing scripts and content. It is not expected that this goal will be met with full backwards compatibility. However, the specification attempts to achieve this when possible.

5.1.1. Terminology

UI events
User interface events. These events are generated by user interaction through an external device (mouse, keyboard, etc.)
UI Logical events
Device independent user interface events such as focus change messages or element triggering notifications.
Mutation events
Events caused by any action which modifies the structure of the document.
Capturing
The process by which an event can be handled by one of the event's target's ancestors before being handled by the event's target.
Bubbling
The process by which an event propagates upward through its ancestors after being handled by the event's target.
Cancellable
A designation for events which indicates that upon handling the event the client may choose to prevent the DOM implementation from processing any default action associated with the event.

5.1.2. Requirements

The following constitutes the list of requirements for the DOM Level 2 Event Model.

(ED: Not all of the requirements below are addressed in the current version of the specification. However, all of the requirements which derive from existing event systems should currently be met.)

Requirements of event flow:

Requirements of event listener registration:

Requirements of contextual event information:

Requirements of event types:



5.2. Description of event flow

Event flow is the process through which the an event originates from the DOM implementation and is passed into the Document Object Model. The methods of event capture and event bubbling, along with various event listener registration techniques, allow the event to then be handled in a number of ways. It can be handled locally at the target Node level or centrally from a Node higher in the document tree.

5.2.1. Basic event flow

Each event has a Node toward which the event is directed by the DOM implementation. This Node is the event target. When the event reaches the target, any event listeners registered on the Node are triggered. Although all EventListeners on the Node are guaranteed to receive the event, no specification is made as to the order in which they will receive the event with regards to the other EventListeners on the Node. If neither event capture or event bubbling are in use for that particular event, the event flow process will complete after all listeners have been triggered. If event capture or event bubbling is in use, the event flow will be modified as described in the sections below.

5.2.2. Event Capture

Event capture is the process by which an ancestor of the event's target can register to intercept events of a given type before they are received by the event's target. Capture operates from the top of the tree downward, making it the symmetrical opposite of bubbling which is described below.

An EventListener being registered on an EventTarget may choose to have that EventListener capture events by specifying the useCapture parameter of the addEventListener method to be true. Thereafter, when an event of the given type is dispatched toward a descendant of the capturing object, the event will trigger any capturing event listeners of the appropriate type which exist in the direct line between the top of the document and the event's target. This downward propagation continues until either no additional capturing EventListeners are found or the event's target is reached.

If the capturing EventListener wishes to prevent further processing of the event it may call the preventCapture method of the Event interface. This will prevent further dispatch of the event to additional EventTargets lower in the tree structure, although additional EventListeners registered at the same hierarchy level will still receive the event. Only one EventListeners is required to call preventCapture to stop the propagation of the event If no additional capturers exist and preventCapture has not been called, the event triggers the appropriate EventListeners on the target itself.

Although event capture is similar to the delegation based event model, it is different in two important respects. First, event capture only allows interception of events which are targeted at descendants of the capturing Node. It does not allow interception of events targeted to the capturer's ancestors, its siblings, or its sibling's descendants. Secondly, event capture is not specified for a single Node, it is specified for a specific type of event. Once specified, event capture intercepts all events of the specified type targeted toward any of the capturer's descendants.

5.2.3. Event bubbling

Events which are designated as bubbling will initially proceed with the same event flow as non-bubbling events. The event is dispatched to its target Node and any event listeners found there are triggered. Bubbling events will then trigger any additional event listeners found by following the Node's parent chain upward, checking for any event listeners registered on each successive Node. This upward propagation will continue up to and including the Document.

Any event handler may choose to prevent continuation of the bubbling process by calling the preventBubble method of the Event interface. If any EventListener calls this method, all additional EventListeners on the current EventTarget will be triggered but bubbling will cease at that level. Only one call to preventBubble is required to prevent further bubbling.

5.2.4. Event cancellation

Some events are specified as cancellable. For these events, the DOM implementation generally has a default action associated with the event. Before processing these events, the implementation must check for event listeners registered to receive the event and dispatch the event to those listeners. These listeners then have the option of cancelling the implementation's default action or allowing the default action to proceed. Cancellation is accomplished by calling the Event's preventDefault method. If one or more EventListeners call preventDefault during any phase of event flow the default action will be cancelled.

5.3. Event listener registration

5.3.1. Event registration interfaces

Interface EventTarget

The EventTarget interface is implemented by all Nodes in an implementation which supports the DOM Event Model. The interface allows event listeners to be registered on the node.

IDL Definition

interface EventTarget {
  void               addEventListener(in DOMString type, 
                                      in EventListener listener, 
                                      in boolean useCapture);
  void               removeEventListener(in DOMString type, 
                                         in EventListener listener, 
                                         in boolean useCapture);
};

Methods
addEventListener
This method allows the registration of event listeners on the event target.
Parameters
type

The event type for which the user is registering

listener

The listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.

useCapture

If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered EventListener before being dispatched to any EventTargets beneath them in the tree. Events which are bubbling upward through the tree will not trigger an EventListener designated to use capture.


This method returns nothing.
This method raises no exceptions.
removeEventListener
This method allows the removal of event listeners from the event target. If an EventListener is removed from an EventTarget while it is processing an event, it will complete its current actions but will not be triggered again during any later stages of event flow.
Parameters
type

Specifies the event type of the EventListener being removed.

listener

The EventListener parameter indicates the EventListener to be removed.

useCapture

Specifies whether the EventListener being removed is a capturing listener or not.


This method returns nothing.
This method raises no exceptions.
Interface EventListener

The EventListener interface is the primary method for handling events. Users implement the EventListener interface and register their listener on a EventTarget using the AddEventListener method. The users should also remove their EventListener from its EventTarget after they have completed using the listener.

IDL Definition

interface EventListener {
  void               handleEvent(in Event event);
};

Methods
handleEvent
This method is called whenever an event occurs of the type for which the EventListener interface was registered.
Parameters
event

The Event contains contextual information about the event. It also contains the returnValue and cancelBubble properties which are used in determining proper event flow.


This method returns nothing.
This method raises no exceptions.

5.3.2. Interaction with HTML 4.0 event listeners

In HTML 4.0, event listeners were specified as properties of an element. As such, registration of a second event listener of the same type would replace the first listener. The DOM Event Model allows registration of multiple event listeners on a single Node. To achieve this, event listeners are no longer stored as property values.

In order to achieve compatibility with HTML 4.0, implementors may view the setting of properties which represent event handlers as the creation and registration of an EventListener on the Node. The value of useCapture defaults to false. This EventListener behaves in the same manner as any other EventListenerss which may be registered on the EventTarget. If the property representing the event listener is changed, this may be viewed as the removal of the previously registered EventListener and the registration of a new one. No technique is provided to allow HTML 4.0 event listeners access to the context information defined for each event.

5.3.3. Event listener registration issues

The specification currently defines listeners as generic listeners which can be registered for multiple types of events. This solution avails itself readily to extending or creating new events. However, registering the same object for multiple events requires the user to differentiate between the events inside the event listener. The current string based event typing system could make this very inefficient. The DOM Working Group is exploring alternatives to the string based event typing to resolve this issue.

A full solution has not yet been added to meet the suggestion that all listeners be notified of the final resolution of an event. It is possible that use of both pre- and post-processed types of events will achieve this goal but it is not yet clear if this solution will be sufficient.

5.4. Event interfaces

Interface Event

The Event interface is used to provide contextual information about an event to the handler processing the event. An object which implements the Event interface is generally passed as the first parameter to an event handler. More specific context information is passed to event handlers by deriving additional interfaces from Event which contain information directly relating to the type of event they accompany. These derived interfaces are also implemented by the object passed to the event listener.

IDL Definition

interface Event {
  // PhaseType
  const unsigned short      BUBBLING_PHASE                 = 1;
  const unsigned short      CAPTURING_PHASE                = 2;
  const unsigned short      AT_TARGET                      = 3;

           attribute DOMString        type;
           attribute Node             target;
           attribute Node             currentNode;
           attribute unsigned short   eventPhase;
  void               preventBubble();
  void               preventCapture();
  void               preventDefault();
};

Definition group PhaseType

An integer indicating which phase of event flow is being processed.

Defined Constants
BUBBLING_PHASE

The current event phase is the bubbling phase.

CAPTURING_PHASE

The current event phase is the capturing phase.

AT_TARGET

The event is currently being evaluated at the target node.

Attributes
type
The type property represents the event name as a string property.
target
The target property indicates the Node to which the event was originally dispatched.
currentNode
The currentNode property indicates to which Node the event is currently being dispatched. This is particularly useful during capturing and bubbling.
eventPhase
The eventPhase property indicates which phase of event flow is currently being evaluated.
Methods
preventBubble
The preventBubble method is used to end the bubbling phase of event flow. If this method is called by any EventListeners registered on the same EventTarget during bubbling, the bubbling phase will cease at that level and the event will not be propagated upward within the tree.
This method has no parameters.
This method returns nothing.
This method raises no exceptions.
preventCapture
The preventCapture method is used to end the capturing phase of event flow. If this method is called by any EventListeners registered on the same EventTarget during capturing, the capturing phase will cease at that level and the event will not be propagated any further down.
This method has no parameters.
This method returns nothing.
This method raises no exceptions.
preventDefault
If an event is cancellable, the preventCapture method is used to signify that the event is to be cancelled. If, during any stage of event flow, the preventDefault method is called the event is cancelled. Any default action associated with the event will not occur. Calling this method for a non-cancellable event has no effect.
This method has no parameters.
This method returns nothing.
This method raises no exceptions.
Interface UIEvent

The UIEvent interface provides specific contextual information associated with User Interface and Logical events.

(ED: The values for the keyCode constants are yet to be determined. )
IDL Definition

interface UIEvent : Event {
  const int                 CHAR_UNDEFINED                 = 1;
  const int                 KEY_FIRST                      = 1;
  const int                 KEY_LAST                       = 1;
  const int                 VK_0                           = 1;
  const int                 VK_1                           = 1;
  const int                 VK_2                           = 1;
  const int                 VK_3                           = 1;
  const int                 VK_4                           = 1;
  const int                 VK_5                           = 1;
  const int                 VK_6                           = 1;
  const int                 VK_7                           = 1;
  const int                 VK_8                           = 1;
  const int                 VK_9                           = 1;
  const int                 VK_A                           = 1;
  const int                 VK_ACCEPT                      = 1;
  const int                 VK_ADD                         = 1;
  const int                 VK_AGAIN                       = 1;
  const int                 VK_ALL_CANDIDATES              = 1;
  const int                 VK_ALPHANUMERIC                = 1;
  const int                 VK_ALT                         = 1;
  const int                 VK_ALT_GRAPH                   = 1;
  const int                 VK_AMPERSAND                   = 1;
  const int                 VK_ASTERISK                    = 1;
  const int                 VK_AT                          = 1;
  const int                 VK_B                           = 1;
  const int                 VK_BACK_QUOTE                  = 1;
  const int                 VK_BACK_SLASH                  = 1;
  const int                 VK_BACK_SPACE                  = 1;
  const int                 VK_BRACELEFT                   = 1;
  const int                 VK_BRACERIGHT                  = 1;
  const int                 VK_C                           = 1;
  const int                 VK_CANCEL                      = 1;
  const int                 VK_CAPS_LOCK                   = 1;
  const int                 VK_CIRCUMFLEX                  = 1;
  const int                 VK_CLEAR                       = 1;
  const int                 VK_CLOSE_BRACKET               = 1;
  const int                 VK_CODE_INPUT                  = 1;
  const int                 VK_COLON                       = 1;
  const int                 VK_COMMA                       = 1;
  const int                 VK_COMPOSE                     = 1;
  const int                 VK_CONTROL                     = 1;
  const int                 VK_CONVERT                     = 1;
  const int                 VK_COPY                        = 1;
  const int                 VK_CUT                         = 1;
  const int                 VK_D                           = 1;
  const int                 VK_DEAD_ABOVEDOT               = 1;
  const int                 VK_DEAD_ABOVERING              = 1;
  const int                 VK_DEAD_ACUTE                  = 1;
  const int                 VK_DEAD_BREVE                  = 1;
  const int                 VK_DEAD_CARON                  = 1;
  const int                 VK_DEAD_CEDILLA                = 1;
  const int                 VK_DEAD_CIRCUMFLEX             = 1;
  const int                 VK_DEAD_DIAERESIS              = 1;
  const int                 VK_DEAD_DOUBLEACUTE            = 1;
  const int                 VK_DEAD_GRAVE                  = 1;
  const int                 VK_DEAD_IOTA                   = 1;
  const int                 VK_DEAD_MACRON                 = 1;
  const int                 VK_DEAD_OGONEK                 = 1;
  const int                 VK_DEAD_SEMIVOICED_SOUND       = 1;
  const int                 VK_DEAD_TILDE                  = 1;
  const int                 VK_DEAD_VOICED_SOUND           = 1;
  const int                 VK_DECIMAL                     = 1;
  const int                 VK_DELETE                      = 1;
  const int                 VK_DIVIDE                      = 1;
  const int                 VK_DOLLAR                      = 1;
  const int                 VK_DOWN                        = 1;
  const int                 VK_E                           = 1;
  const int                 VK_END                         = 1;
  const int                 VK_ENTER                       = 1;
  const int                 VK_EQUALS                      = 1;
  const int                 VK_ESCAPE                      = 1;
  const int                 VK_EURO_SIGN                   = 1;
  const int                 VK_EXCLAMATION_MARK            = 1;
  const int                 VK_F                           = 1;
  const int                 VK_F1                          = 1;
  const int                 VK_F10                         = 1;
  const int                 VK_F11                         = 1;
  const int                 VK_F12                         = 1;
  const int                 VK_F13                         = 1;
  const int                 VK_F14                         = 1;
  const int                 VK_F15                         = 1;
  const int                 VK_F16                         = 1;
  const int                 VK_F17                         = 1;
  const int                 VK_F18                         = 1;
  const int                 VK_F19                         = 1;
  const int                 VK_F2                          = 1;
  const int                 VK_F20                         = 1;
  const int                 VK_F21                         = 1;
  const int                 VK_F22                         = 1;
  const int                 VK_F23                         = 1;
  const int                 VK_F24                         = 1;
  const int                 VK_F3                          = 1;
  const int                 VK_F4                          = 1;
  const int                 VK_F5                          = 1;
  const int                 VK_F6                          = 1;
  const int                 VK_F7                          = 1;
  const int                 VK_F8                          = 1;
  const int                 VK_F9                          = 1;
  const int                 VK_FINAL                       = 1;
  const int                 VK_FIND                        = 1;
  const int                 VK_FULL_WIDTH                  = 1;
  const int                 VK_G                           = 1;
  const int                 VK_GREATER                     = 1;
  const int                 VK_H                           = 1;
  const int                 VK_HALF_WIDTH                  = 1;
  const int                 VK_HELP                        = 1;
  const int                 VK_HIRAGANA                    = 1;
  const int                 VK_HOME                        = 1;
  const int                 VK_I                           = 1;
  const int                 VK_INSERT                      = 1;
  const int                 VK_INVERTED_EXCLAMATION_MARK   = 1;
  const int                 VK_J                           = 1;
  const int                 VK_JAPANESE_HIRAGANA           = 1;
  const int                 VK_JAPANESE_KATAKANA           = 1;
  const int                 VK_JAPANESE_ROMAN              = 1;
  const int                 VK_K                           = 1;
  const int                 VK_KANA                        = 1;
  const int                 VK_KANJI                       = 1;
  const int                 VK_KATAKANA                    = 1;
  const int                 VK_KP_DOWN                     = 1;
  const int                 VK_KP_LEFT                     = 1;
  const int                 VK_KP_RIGHT                    = 1;
  const int                 VK_KP_UP                       = 1;
  const int                 VK_L                           = 1;
  const int                 VK_LEFT                        = 1;
  const int                 VK_LEFT_PARENTHESIS            = 1;
  const int                 VK_LESS                        = 1;
  const int                 VK_M                           = 1;
  const int                 VK_META                        = 1;
  const int                 VK_MINUS                       = 1;
  const int                 VK_MODECHANGE                  = 1;
  const int                 VK_MULTIPLY                    = 1;
  const int                 VK_N                           = 1;
  const int                 VK_NONCONVERT                  = 1;
  const int                 VK_NUM_LOCK                    = 1;
  const int                 VK_NUMBER_SIGN                 = 1;
  const int                 VK_NUMPAD0                     = 1;
  const int                 VK_NUMPAD1                     = 1;
  const int                 VK_NUMPAD2                     = 1;
  const int                 VK_NUMPAD3                     = 1;
  const int                 VK_NUMPAD4                     = 1;
  const int                 VK_NUMPAD5                     = 1;
  const int                 VK_NUMPAD6                     = 1;
  const int                 VK_NUMPAD7                     = 1;
  const int                 VK_NUMPAD8                     = 1;
  const int                 VK_NUMPAD9                     = 1;
  const int                 VK_O                           = 1;
  const int                 VK_OPEN_BRACKET                = 1;
  const int                 VK_P                           = 1;
  const int                 VK_PAGE_DOWN                   = 1;
  const int                 VK_PAGE_UP                     = 1;
  const int                 VK_PASTE                       = 1;
  const int                 VK_PAUSE                       = 1;
  const int                 VK_PERIOD                      = 1;
  const int                 VK_PLUS                        = 1;
  const int                 VK_PREVIOUS_CANDIDATE          = 1;
  const int                 VK_PRINTSCREEN                 = 1;
  const int                 VK_PROPS                       = 1;
  const int                 VK_Q                           = 1;
  const int                 VK_QUOTE                       = 1;
  const int                 VK_QUOTEDBL                    = 1;
  const int                 VK_R                           = 1;
  const int                 VK_RIGHT                       = 1;
  const int                 VK_RIGHT_PARENTHESIS           = 1;
  const int                 VK_ROMAN_CHARACTERS            = 1;
  const int                 VK_S                           = 1;
  const int                 VK_SCROLL_LOCK                 = 1;
  const int                 VK_SEMICOLON                   = 1;
  const int                 VK_SEPARATER                   = 1;
  const int                 VK_SHIFT                       = 1;
  const int                 VK_SLASH                       = 1;
  const int                 VK_SPACE                       = 1;
  const int                 VK_STOP                        = 1;
  const int                 VK_SUBTRACT                    = 1;
  const int                 VK_T                           = 1;
  const int                 VK_TAB                         = 1;
  const int                 VK_U                           = 1;
  const int                 VK_UNDEFINED                   = 1;
  const int                 VK_UNDERSCORE                  = 1;
  const int                 VK_UNDO                        = 1;
  const int                 VK_UP                          = 1;
  const int                 VK_V                           = 1;
  const int                 VK_W                           = 1;
  const int                 VK_X                           = 1;
  const int                 VK_Y                           = 1;
  const int                 VK_Z                           = 1;
           attribute long             screenX;
           attribute long             screenY;
           attribute long             clientX;
           attribute long             clientY;
           attribute boolean          ctrlKey;
           attribute boolean          shiftKey;
           attribute boolean          altKey;
           attribute boolean          metaKey;
           attribute unsigned long    keyCode;
           attribute unsigned long    charCode;
           attribute unsigned short   button;
           attribute unsigned short   clickCount;
};

Constant CHAR_UNDEFINED

KEY_PRESSED and KEY_RELEASED events which do not map to a valid Unicode character use this for the keyChar value.

Constant KEY_FIRST

The first number in the range of ids used for key events.

Constant KEY_LAST

The last number in the range of ids used for key events.

Constant VK_0

VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39)

Constant VK_1
Constant VK_2
Constant VK_3
Constant VK_4
Constant VK_5
Constant VK_6
Constant VK_7
Constant VK_8
Constant VK_9
Constant VK_A

VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A)

Constant VK_ACCEPT
Constant VK_ADD
Constant VK_AGAIN
Constant VK_ALL_CANDIDATES

Constant for the All Candidates function key.

Constant VK_ALPHANUMERIC

Constant for the Alphanumeric function key.

Constant VK_ALT
Constant VK_ALT_GRAPH

Constant for the AltGraph modifier key.

Constant VK_AMPERSAND
Constant VK_ASTERISK
Constant VK_AT

Constant for the "@" key.

Constant VK_B
Constant VK_BACK_QUOTE
Constant VK_BACK_SLASH
Constant VK_BACK_SPACE
Constant VK_BRACELEFT
Constant VK_BRACERIGHT
Constant VK_C
Constant VK_CANCEL
Constant VK_CAPS_LOCK
Constant VK_CIRCUMFLEX

Constant for the "^" key.

Constant VK_CLEAR
Constant VK_CLOSE_BRACKET
Constant VK_CODE_INPUT

Constant for the Code Input function key.

Constant VK_COLON

Constant for the ":" key.

Constant VK_COMMA
Constant VK_COMPOSE

Constant for the Compose function key.

Constant VK_CONTROL
Constant VK_CONVERT
Constant VK_COPY
Constant VK_CUT
Constant VK_D
Constant VK_DEAD_ABOVEDOT
Constant VK_DEAD_ABOVERING
Constant VK_DEAD_ACUTE
Constant VK_DEAD_BREVE
Constant VK_DEAD_CARON
Constant VK_DEAD_CEDILLA
Constant VK_DEAD_CIRCUMFLEX
Constant VK_DEAD_DIAERESIS
Constant VK_DEAD_DOUBLEACUTE
Constant VK_DEAD_GRAVE
Constant VK_DEAD_IOTA
Constant VK_DEAD_MACRON
Constant VK_DEAD_OGONEK
Constant VK_DEAD_SEMIVOICED_SOUND
Constant VK_DEAD_TILDE
Constant VK_DEAD_VOICED_SOUND
Constant VK_DECIMAL
Constant VK_DELETE
Constant VK_DIVIDE
Constant VK_DOLLAR

Constant for the "$" key.

Constant VK_DOWN
Constant VK_E
Constant VK_END
Constant VK_ENTER
Constant VK_EQUALS
Constant VK_ESCAPE
Constant VK_EURO_SIGN

Constant for the Euro currency sign key.

Constant VK_EXCLAMATION_MARK

Constant for the "!" key.

Constant VK_F
Constant VK_F1

Constant for the F1 function key.

Constant VK_F10

Constant for the F10 function key.

Constant VK_F11

Constant for the F11 function key.

Constant VK_F12

Constant for the F12 function key.

Constant VK_F13

Constant for the F13 function key.

Constant VK_F14

Constant for the F14 function key.

Constant VK_F15

Constant for the F15 function key.

Constant VK_F16

Constant for the F16 function key.

Constant VK_F17

Constant for the F17 function key.

Constant VK_F18

Constant for the F18 function key.

Constant VK_F19

Constant for the F19 function key.

Constant VK_F2

Constant for the F2 function key.

Constant VK_F20

Constant for the F20 function key.

Constant VK_F21

Constant for the F21 function key.

Constant VK_F22

Constant for the F22 function key.

Constant VK_F23

Constant for the F23 function key.

Constant VK_F24

Constant for the F24 function key.

Constant VK_F3

Constant for the F3 function key.

Constant VK_F4

Constant for the F4 function key.

Constant VK_F5

Constant for the F5 function key.

Constant VK_F6

Constant for the F6 function key.

Constant VK_F7

Constant for the F7 function key.

Constant VK_F8

Constant for the F8 function key.

Constant VK_F9

Constant for the F9 function key.

Constant VK_FINAL
Constant VK_FIND
Constant VK_FULL_WIDTH

Constant for the Full-Width Characters function key.

Constant VK_G
Constant VK_GREATER
Constant VK_H
Constant VK_HALF_WIDTH

Constant for the Half-Width Characters function key.

Constant VK_HELP
Constant VK_HIRAGANA

Constant for the Hiragana function key.

Constant VK_HOME
Constant VK_I
Constant VK_INSERT
Constant VK_INVERTED_EXCLAMATION_MARK

Constant for the inverted exclamation mark key.

Constant VK_J
Constant VK_JAPANESE_HIRAGANA

Constant for the Japanese-Hiragana function key.

Constant VK_JAPANESE_KATAKANA

Constant for the Japanese-Katakana function key.

Constant VK_JAPANESE_ROMAN

Constant for the Japanese-Roman function key.

Constant VK_K
Constant VK_KANA
Constant VK_KANJI
Constant VK_KATAKANA

Constant for the Katakana function key.

Constant VK_KP_DOWN

for KeyPad cursor arrow keys

Constant VK_KP_LEFT

for KeyPad cursor arrow keys

Constant VK_KP_RIGHT

for KeyPad cursor arrow keys

Constant VK_KP_UP

for KeyPad cursor arrow keys

Constant VK_L
Constant VK_LEFT
Constant VK_LEFT_PARENTHESIS

Constant for the "(" key.

Constant VK_LESS
Constant VK_M
Constant VK_META
Constant VK_MINUS
Constant VK_MODECHANGE
Constant VK_MULTIPLY
Constant VK_N
Constant VK_NONCONVERT
Constant VK_NUM_LOCK
Constant VK_NUMBER_SIGN

Constant for the "#" key.

Constant VK_NUMPAD0
Constant VK_NUMPAD1
Constant VK_NUMPAD2
Constant VK_NUMPAD3
Constant VK_NUMPAD4
Constant VK_NUMPAD5
Constant VK_NUMPAD6
Constant VK_NUMPAD7
Constant VK_NUMPAD8
Constant VK_NUMPAD9
Constant VK_O
Constant VK_OPEN_BRACKET
Constant VK_P
Constant VK_PAGE_DOWN
Constant VK_PAGE_UP
Constant VK_PASTE
Constant VK_PAUSE
Constant VK_PERIOD
Constant VK_PLUS

Constant for the "+" key.

Constant VK_PREVIOUS_CANDIDATE

Constant for the Previous Candidate function key.

Constant VK_PRINTSCREEN
Constant VK_PROPS
Constant VK_Q
Constant VK_QUOTE
Constant VK_QUOTEDBL
Constant VK_R
Constant VK_RIGHT
Constant VK_RIGHT_PARENTHESIS

Constant for the ")" key.

Constant VK_ROMAN_CHARACTERS

Constant for the Roman Characters function key.

Constant VK_S
Constant VK_SCROLL_LOCK
Constant VK_SEMICOLON
Constant VK_SEPARATER
Constant VK_SHIFT
Constant VK_SLASH
Constant VK_SPACE
Constant VK_STOP
Constant VK_SUBTRACT
Constant VK_T
Constant VK_TAB
Constant VK_U
Constant VK_UNDEFINED

KEY_TYPED events do not have a keyCode value.

Constant VK_UNDERSCORE

Constant for the "_" key.

Constant VK_UNDO
Constant VK_UP
Constant VK_V
Constant VK_W
Constant VK_X
Constant VK_Y
Constant VK_Z
Attributes
screenX
screenX indicates the horizontal coordinate at which the event occurred in relative to the origin of the screen coordinate system.
screenY
screenY indicates the vertical coordinate at which the event occurred relative to the origin of the screen coordinate system.
clientX
clientX indicates the horizontal coordinate at which the event occurred relative to the DOM implementation's client area.
clientY
clientY indicates the vertical coordinate at which the event occurred relative to the DOM implementation's client area.
ctrlKey
ctrlKey indicates whether the 'ctrl' key was depressed during the firing of the event.
shiftKey
shiftKey indicates whether the 'shift' key was depressed during the firing of the event.
altKey
altKey indicates whether the 'alt' key was depressed during the firing of the event. On some platforms this key may map to an alternative key name.
metaKey
metaKey indicates whether the 'meta' key was depressed during the firing of the event. On some platforms this key may map to an alternative key name.
keyCode
The value of keyCode holds the virtual key code value of the key which was depressed if the event is a key event. Otherwise, the value is zero.
charCode
charCode holds the value of the Unicode character associated with the depressed key if the event is a key event. Otherwise, the value is zero.
button
During mouse events caused by the depression or release of a mouse button, button is used to indicate which mouse button changed state.
clickCount
The clickCount property indicates the number of times a mouse button has been pressed and released over the same screen location during a user action. The property value is 1 when the user begins this action and increments by 1 for each full sequence of pressing and releasing. If the user moves the mouse between the mousedown and mouseup the value will be set to 0, indicating that no click is occurring.
Interface MutationEvent

The MutationEvent interface provides specific contextual information associated with Mutation events.

IDL Definition

interface MutationEvent : Event {
           attribute Node             relatedNode;
           attribute DOMString        prevValue;
           attribute DOMString        newValue;
           attribute DOMString        attrName;
};

Attributes
relatedNode
relatedNode is used to identify a secondary node related to a mutation event. For example, if a mutation event is dispatched to a node indicating that its parent has changed, the relatedNode is the changed parent. If an event is instead dispatch to a subtree indicating a node was changed within it, the relatedNode is the changed node.
prevValue
prevValue indicates the previous value of text nodes and attributes in attrModified and charDataModified events.
newValue
newValue indicates the new value of text nodes and attributes in attrModified and charDataModified events.
attrName
attrName indicates the changed attr in the attrModified event.

5.5. Event set definitions

The DOM Level 2 Event Model allows a DOM implementation to support multiple sets of events. The model has been designed to allow addition of new event sets as is required. The DOM will not attempt to define all possible events. For purposes of interoperability, the DOM will define a set of user interface events, a set of UI logical events, and a set of document mutation events.

5.5.1. User Interface event types

The User Interface event set is composed of events listed in HTML 4.0 and additional events which are supported in both Netscape Navigator 4.0 and Microsoft Internet Explorer 4.0.

click
The click event occurs when the pointing device button is clicked over an element. A click is defined as a mousedown and mouseup over the same screen location. The sequence of these events is:

    mousedown
    mouseup
    click
    
If multiple clicks occur at the same screen location, the sequence repeats with the clickCount property incrementing with each repetition. This event is valid for most elements.
mousedown
The mousedown event occurs when the pointing device button is pressed over an element. This event is valid for most elements.
mouseup
The mouseup event occurs when the pointing device button is released over an element. This event is valid for most elements.
mouseover
The mouseover event occurs when the pointing device is moved onto an element. This event is valid for most elements.
mousemove
The mousemove event occurs when the pointing device is moved while it is over an element. This event is valid for most elements.
mouseout
The mouseout event occurs when the pointing device is moved away from an element. This event is valid for most elements..
keypress
The keypress event occurs when a key is pressed. If the key remains depressed, multiple keypresses may be generated. This event maps not to the physical depression of the key but is instead the result of that action, often being the insertion of a character.
keydown
The keydown event occurs when a key is pressed down.
keyup
The keyup event occurs when a key is released.
resize
The resize event occurs when a document is resized.
scroll
The scroll event occurs when a document is scrolled.

5.5.2. Mutation event types

The mutation event set is designed to allow notification of any changes to the structure of a document, including attr and text modifications. It may be noted that none of the mutation events listed are designated as cancellable. The reasoning for this stems from the fact that it would be very difficult to make use of existing DOM interfaces which cause document modifications if any change to the document might or might not take place due to cancellation of the related event. Although this is still a desired capability, it was decided that it would be better left until the addition of transactions into the DOM.

subtreeModified
This is a general event for notification of all changes to the document. It can be used instead of the more specific events listed below. Also, the requirement for some sort of batching of mutation events may be accomplished through this event. The target of this event is the lowest common parent of the changes which have taken place. This event is dispatched after any other events caused by the mutation have fired.
nodeInserted
Fired when a node has been added as a child of another node. This event is dispatched after the insertion has taken place. The target of this event is the node being inserted.
nodeRemoved
Fired when a node is being removed from another node. This event is dispatched before the node is removed from the tree. The target of this event is the node being removed.
nodeRemovedFromDocument
Fired when a node is being removed from a document, either through direct removal of the Node or removal of a subtree in which it is contained. This event is dispatched before the removal takes place. The target of this event is the node being removed. If the Node is being directly removed the nodeRemoved event will fire before the nodeRemovedFromDocument event.
nodeInsertedIntoDocument
Fired when a node is being inserted into a document, either through direct insertion of the Node or insertion of a subtree in which it is contained. This event is dispatched after the insertion has taken place. The target of this event is the node being inserted. If the Node is being directly inserted the nodeInserted event will fire before the nodeInsertedIntoDocument event.
attrModified
Fired after an Attr has been modified on a node. The target of this event is the node whose Attr changed.
characterDataModified
Fired after CharacterData within a node has been modified but the node itself has not been inserted or deleted. The target of this event is the CharacterData node.

5.5.3. HTML event types

The HTML event set is composed of events listed in HTML 4.0 and additional events which are supported in both Netscape Navigator 4.0 and Microsoft Internet Explorer 4.0.

load
The load event occurs when the DOM implementation finishes loading all content within a document, all frames within a FRAMESET, or an image.
unload
The unload event occurs when the DOM implementation removes a document from a window or frame. This event is valid for BODY and FRAMESET elements.
abort
The abort event occurs when page loading is stopped before an image has been allowed to completely load. This event applies to IMG elements.
error
The error event occurs when an image does not load properly or when an error occurs during script execution. This event is valid for IMG elements, BODY elements, and FRAMESET element.
select
The select event occurs when a user selects some text in a text field. This event is valid for INPUT and TEXTAREA elements.
change
The change event occurs when a control loses the input focus and its value has been modified since gaining focus. This event is valid for INPUT, SELECT, and TEXTAREA. element.
submit
The submit event occurs when a form is submitted. This event only applies to the FORM element.
reset
The reset event occurs when a form is reset. This event only applies to the FORM element.
focus
The focus event occurs when an element receives focus either via a pointing device or by tabbing navigation. This event is valid for the following elements: LABEL, INPUT, SELECT, TEXTAREA, and BUTTON.
blur
The blur event occurs when an element loses focus either by the pointing device or by tabbing navigation. This event is valid for the following elements: LABEL, INPUT, SELECT, TEXTAREA, and BUTTON.