# addeventlistener

> `addEventListener` that takes options as an object and returns a function to remove the listener.

Latest version **2.0.0** (published 2017-08-25) · CC0-1.0 license · 0 weekly downloads

## Install

```sh
npm install addeventlistener
pnpm add addeventlistener
yarn add addeventlistener
bun add addeventlistener
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2017-08-25 |
| First published | 2017-08-10 |
| Weekly downloads | 0 |
| License | CC0-1.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Johnny Hauser |
| Maintainers | m59 |
| Keywords | addEventListener, removeEventListener, return, unlisten, stop, once, one, browser, options, object, modern |

## Links

- npm: https://www.npmjs.com/package/addeventlistener
- Repository: https://github.com/m59peacemaker/browser-addeventlistener
- Homepage: https://github.com/m59peacemaker/browser-addeventlistener#readme
- Issues: https://github.com/m59peacemaker/browser-addeventlistener/issues
- npm.io page: https://npm.io/package/addeventlistener

## Dependencies (1)

- [event-listener-with-options](https://npm.io/package/event-listener-with-options.md) ^1.0.3

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2017-08-25
- 1.0.0 — 2017-08-10

## README

# addeventlistener

`addEventListener` that takes options as an object and returns a function to remove the listener.

## install

```sh
$ npm install addeventlistener
```

## api

### `addEventListener(element, eventName, listener, options)`

```js
import addEventListener from 'addeventlistener'

const removeEventListener = addEventListener(
  document.body,
  'touchmove',
  e => {},
  { passive: false }
)
```

### `once(element, eventName, listener, options)`

Listen for the event and stop listening after it has occurred once. You can still use the returned function to stop listening if you want to stop listening before the event has occurred once.

```js
import { once } from 'addeventlistener'

const removeEventListener = once(window, 'click', console.log)
```

### CommonJS

```js
const { default: addEventListener, once } = require('addeventlistener')
```

---
_Source: https://npm.io/package/addeventlistener · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
