The Event Object

When the user clicks, a resource loads or a socket receives a message, the browser creates an Event object, computes the propagation path from Window down to the target, and passes that one object to every listener on the path. Each listener can read what happened (type, target, coordinates, keys) and change what happens next.

Dispatch runs in three phases: capture from Window down to the target's parent (listeners registered with capture: true), target, and bubble back up to Window (ordinary listeners), the last only when event.bubbles is true: click and input bubble; focus, load and mouseenter do not.

The capture, target and bubble phases of a click on a button
The capture, target and bubble phases of a click on a button

Subsections