mouse-pressed
Simple module to detect if a mouse button is pressed or not.
Last updated 5 years ago by hughsk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mouse-pressed 
SYNC missed versions from official npm registry.

mouse-pressed experimental

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

Usage

NPM

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 for details.

Current Tags

  • 1.0.0                                ...           latest (5 years ago)

3 Versions

  • 1.0.0                                ...           5 years ago
  • 0.0.1                                ...           7 years ago
  • 0.0.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 6
Last Day 0
Last Week 3
Last Month 15
Dependencies (1)
Dev Dependencies (1)

Copyright 2014 - 2017 © taobao.org |