Events are the heartbeat of interactive web applications, turning static documents into living software that responds to user input.
1The Event Categories
Events can be broadly categorized into Mouse Events (click, mouseover), Keyboard Events (keydown, keyup), and Form Events (submit, change, input). By attaching listeners to DOM elements using addEventListener, you tell the browser to execute a specific callback function whenever that interaction occurs.
2The Event Object & Default Behavior
When an event fires, it automatically passes an Event Object to your callback function. This object contains vital metadata, like which key was pressed (event.key) or the mouse coordinates. Crucially, it provides the event.preventDefault() method, which allows you to stop the browser from executing its default action (like refreshing the page when a form is submitted).
