mikolalysenko / mouse-change

Mouse state change listener
https://mikolalysenko.github.io/mouse-change
MIT License
15 stars 1 forks source link

mouse-change

Listens for any mouse state changes.

Example

require('mouse-change')(function(buttons, x, y) {
  document.body.innerHTML =
    '<p>Buttons: 0b' + buttons.toString(2) +
    ', x:' + x +
    ', y:' + y + '</p>'
})

Try it out in your browser

Install

npm i mouse-change

API

var l = require('mouse-change')([element, onchange(buttons,x,y,mods)])

Listens for any mouse state changes on the given element.

Returns A new listener object which can be used to configure the listener.

l.enabled

Toggles whether or not

l.x

The x coordinate of the mouse

l.y

The y coordinate of the mouse

l.buttons

The button state of the mouse

l.mods

The current state of the keyboard modifiers

License

(c) 2015 Mikola Lysenko. MIT License