# mouse-pressed

> Simple module to detect if a mouse button is pressed or not.

Latest version **1.0.0** (published 2015-11-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install mouse-pressed
pnpm add mouse-pressed
yarn add mouse-pressed
bun add mouse-pressed
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-11-19 |
| First published | 2014-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | mouse, pressed, down, up, click, event, watch |

## Links

- npm: https://www.npmjs.com/package/mouse-pressed
- Repository: https://github.com/hughsk/mouse-pressed
- Issues: https://github.com/hughsk/mouse-pressed/issues
- npm.io page: https://npm.io/package/mouse-pressed

## Dependencies (1)

- [events](https://npm.io/package/events.md) ^1.0.1

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-11-19
- 0.0.1 — 2014-05-13
- 0.0.0 — 2014-05-13

## README

# mouse-pressed [![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)

Simple module to detect if a mouse button is pressed or not.

## Usage

[![NPM](https://nodei.co/npm/mouse-pressed.png)](https://nodei.co/npm/mouse-pressed/)

### pressed = mousePressed(element, [preventDefault])

Watch mouse events on `element` (defaults to `window`).

Passing `preventDefault` as `true` will disable mouse actions on the element
in question – including right clicks, which is sometimes useful for games.

### pressed.left

`true` or `false`, depending whether the left mouse button is pressed down.

### pressed.right

`true` or `false`, depending whether the right mouse button is pressed down.

### pressed.middle

`true` or `false`, depending whether the middle mouse button is pressed down.

### pressed.on('down', callback(event))

Emitted with the original mouse `event` every time a mouse button is pressed.

### pressed.on('up', callback(event))

Emitted with the original mouse `event` every time a mouse button is released.

### pressed.dispose()

To be called when this instance is no longer required: removes all of the attached event listeners.

## License

MIT. See [LICENSE.md](http://github.com/hughsk/mouse-pressed/blob/master/LICENSE.md) for details.

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