# Browser Event

> A sign that something happened on a page, like a click. Code can react to it.

**Field:** Software Development  
**Category:** Web Development  
**Also known as:** DOM Event, Event Listener, JavaScript Event

## Think of it like

Think of it like a doorbell. When someone presses it, the person inside hears it and goes to the door.

## Definition

A browser event is a signal that something just happened on a page. It could be a click, a key press or the page finishing loading. JavaScript can listen for an event on any part of the page. When it happens, the browser runs the function you gave it, called an event handler. This is how buttons, menus and forms respond to people. Without events, a page could not react to anything.

## Example

Jack's page listens for clicks on the Buy button. Each click runs a function that adds the item to the cart.

## Example code

```javascript
button.addEventListener("click", () => {
  console.log("Clicked!");
});
```

Each click on the button runs the code inside.

## Why it matters

Events are how a page talks back. Every click, tap and key press is one.

## Common mistake

Adding the same listener again each time something renders. The code then runs twice, three times, and more.

## Three principles

- **Something happened.** A click, a key, a load.
- **Listen for it.** Attach a handler to a part.
- **Run a function.** The browser calls your code.

## Related terms

- [Document Object Model (DOM)](https://learn.benibix.com/term/development/dom)
- [JavaScript](https://learn.benibix.com/term/development/javascript)
- [Function](https://learn.benibix.com/term/development/function)
- [HTML Form](https://learn.benibix.com/term/development/html-form)

## Taught in

- [JavaScript and the DOM](https://learn.benibix.com/learn/development-web/javascript-and-the-dom): HTML, CSS and JS, 12/14

---

Source: https://learn.benibix.com/term/development/browser-event
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
