I’ve been wiring up keyboard shortcuts lately and needed a quick refresher on DOM events.
Event Flow Visualization
JavaScript APIs
- Binding events is straightforward. Use
addEventListener, and pass the third argument to opt into the capture phase. For pure bubbling, handlers likeonclickwork too. - The
event.stopPropagation()method halts propagation—whether the event is bubbling or capturing—exactly as the diagram shows. event.preventDefault()doesn’t stop propagation, but it blocks default behaviors such as following a link when clicking an<a>tag.
References
done

