stopEvent function Utility

void stopEvent(
  1. Event event
)

Stops the propagation and prevents the default action of a browser Event.

This is a common utility function to call on events (like mouse clicks, key presses, or touch events) to prevent them from bubbling up the DOM tree or triggering default browser behaviors (e.g., form submission, context menu).

Implementation

void stopEvent(Event event) {
  event.stopPropagation();
  event.preventDefault();
}