Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/mouse-change
Mouse state change listener
https://github.com/mikolalysenko/mouse-change
Last synced: about 2 months ago
JSON representation
Mouse state change listener
- Host: GitHub
- URL: https://github.com/mikolalysenko/mouse-change
- Owner: mikolalysenko
- License: mit
- Created: 2015-02-16T23:27:55.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-11-27T17:18:18.000Z (about 8 years ago)
- Last Synced: 2024-04-19T21:21:26.472Z (8 months ago)
- Language: JavaScript
- Homepage: https://mikolalysenko.github.io/mouse-change
- Size: 8.79 KB
- Stars: 15
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
mouse-change
============
Listens for any mouse state changes.# Example
```javascript
require('mouse-change')(function(buttons, x, y) {
document.body.innerHTML =
'Buttons: 0b' + buttons.toString(2) +
'
', x:' + x +
', y:' + y + '
})
```[Try it out in your browser](https://mikolalysenko.github.io/mouse-change)
# 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.* `element` is an optional element
* `onchange(buttons,x,y,mods)` is an optional callback which gets called every time that the mouse state changes inside `element`
+ `buttons` is the state of the mouse buttons
+ `x` is the x coordinate of the mouse
+ `y` is the y coordinate of the mouse
+ `mods` is an object storing the state of any key modifiers
* `mods.shift` is the state of the shift key
* `mods.alt` is the state of then alt key
* `mods.control` is the state of the control key
* `mods.meta` is the state of the meta key**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