Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kapetan/osx-mouse
Mouse tracking for OS X
https://github.com/kapetan/osx-mouse
Last synced: about 2 months ago
JSON representation
Mouse tracking for OS X
- Host: GitHub
- URL: https://github.com/kapetan/osx-mouse
- Owner: kapetan
- Created: 2015-05-03T23:13:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-03-15T14:24:23.000Z (6 months ago)
- Last Synced: 2024-04-24T02:01:09.238Z (5 months ago)
- Language: C++
- Size: 48.8 KB
- Stars: 73
- Watchers: 3
- Forks: 22
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome - kapetan/osx-mouse - Mouse tracking for OS X (C++)
README
# osx-mouse
Mouse tracking for OS X. Receive the screen position of various mouse events. The events are also emitted while another application is in the foreground.
Versions of this library prior to version 2.0.0 also run with Node.js version 9 and below. Version 2.0.0 and above are context-aware.
npm install osx-mouse
# Usage
The module returns an event emitter instance.
```javascript
var mouse = require('osx-mouse')()mouse.on('move', function(x, y) {
console.log(x, y)
})
```The program will not terminate as long as a mouse listener is active. To allow the program to exit, either call `mouse.unref` (works as `unref`/`ref` on a TCP server) or `mouse.destroy()`.
The events emitted are: `move`, `left-down`, `left-up`, `left-drag`, `right-up`, `right-down` and `right-drag`. For each event the screen coordinates are passed to the handler function.
# Limitations
From *macOS Mojave* and forward this library requires input capturing permissions which need to be granted manually.
E.g. in *macOS Catalina* when running from *Terminal*:
1. Open `System Preferences > Security & Privacy > Input Monitoring`
2. Add *Terminal* to the list