Event Listeners
Make your page react to clicks, typing, scrolling, and more — events are how JavaScript knows the user did something.
Step 1 of 5
Events: the browser is always watching
Every time you click, type, scroll, hover, resize the window, or even just move your mouse, the browser creates an **event** — a JavaScript object that describes exactly what happened. Without events, JavaScript would just run once when the page loads and then sit idle forever.
Events are the heartbeat of interactive websites. When you click 'Like' on Instagram, a `click` event fires. When you type in Google's search bar, an `input` event fires on every keystroke. When you submit a login form, a `submit` event fires. JavaScript listens for these events and runs your code in response.
Think of it this way: An event listener is like a doorbell. You install it once (`addEventListener`), and every time someone presses it (triggers the event), your function runs — like answering the door. You can install different doorbells for different actions: one for knocking (click), one for mail delivery (input), one for emergencies (submit).
Learn more on MDN