```
## Custom Events
Custom events work too. Dispatch them from JavaScript with [`htmx.trigger()`](/reference/methods/htmx-trigger), or from the server via the [`HX-Trigger`](/reference/headers/HX-Trigger) response header.
Events from `HX-Trigger` are dispatched on the `body`, so use [`from:body`](#from) to listen for them:
```html
...
```
## Synthetic Events
htmx provides synthetic events beyond standard DOM events:
### `load`
Fires when the element is loaded into the DOM. Useful for [lazy-loading](/patterns/loading/lazy-load) content.
```html
Loading...
```
### `revealed`
Fires when the element is scrolled into the viewport. Useful for [infinite scroll](/patterns/loading/infinite-scroll).
```html
Loading...
```
_Note: `revealed` always observes the browser viewport. For scrollable containers with `overflow`, use [`intersect`](#intersect) with `root` instead._
### `intersect`
Fires when an element becomes visible in the viewport.
Uses the [IntersectionObserver API](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/IntersectionObserver#options) and supports [`root`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/root), [`rootMargin`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin), and [`threshold`](https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/thresholds) as modifiers.
```html
...
...
...
...
```
### `every
`
Fires repeatedly on an interval.
```html
...
```
To add a filter to polling, add it after the interval:
```html
...
```
## Event Modifiers
### `[filter]`
A JavaScript expression in brackets after the event name. Only fires when it evaluates to `true`.
```html
```
Inside the brackets, all properties of the event are available as bare names:
- [`click`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent#instance_properties) → `altKey`, `ctrlKey`, `shiftKey`, `metaKey`, ...
- [`keydown`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#instance_properties) → `key`, `code`, `repeat`, ...
Global functions work too: `click[hasUnsavedChanges()]`.
### `once`
Fires once, then stops listening.
```html
Load Once
```
### `changed`
Only fires if the element's `value` changed since last time.
```html
```
Note: [`change`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event) is a DOM event. `changed` is an htmx modifier. Different things.
### `delay:`
Waits before firing. If the event fires again, the delay resets (debounce).
```html
```
### `throttle:`
Fires, then ignores further events for the given interval.
```html
...
```
### `from:`
Listens on a different element. Takes a CSS selector or an [extended selector](/docs#extended-selectors-1). Two special values: `self` (only the element itself, not children) and `outside` (anything outside the element).
```html
...
...
...
...
...
```
### `target:`
Only fires if `event.target` matches the given CSS selector.
```html
...
```
### `prevent`
Calls `event.preventDefault()`.
```html
```
### `stop` / `consume`
Calls `event.stopPropagation()`.
```html
...
```
### `halt`
Shorthand for `prevent stop`.
```html
...
```
### `capture`
Listens during the capture phase (top-down) instead of the bubble phase (bottom-up).
```html
...
```
### `passive`
Tells the browser the handler won't call `preventDefault()`, so the browser can scroll without waiting for your code to finish.
```html
...
```
### Example
A search box that searches on `input`, but only if the value has [`changed`](#changed) and the user hasn't typed anything new for 1 second ([`delay`](#delay)):
```html
```
## Notes
* Selectors with whitespace in [`from`](#from) or [`target`](#target) need parentheses: `from:(form input)`.
* `hx-trigger="change, reset"` may fire before the browser resets the form. As a workaround, add a short delay: `hx-trigger="change, reset delay:0.01s"`.
## See Also
- [`hx-on`](/reference/attributes/hx-on) (attribute)
- [Extended Selectors](/docs#extended-selectors-1) (reference)
- [Lazy Load](/patterns/loading/lazy-load) (pattern)
- [Infinite Scroll](/patterns/loading/infinite-scroll) (pattern)
- [Progress Bar](/patterns/loading/progress-bar) (pattern)