Skip to content

Mouse tracking for macOS using Cocoa APIs

Notifications You must be signed in to change notification settings

bobrippling/osx-mouse-cocoa

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

osx-mouse-cocoa

Mouse tracking for macOS. Receive the screen position of various mouse events.

npm install osx-mouse-cocoa

This is a fork of osx-mouse that works on macOS Mojave without accessibility permissions. Unlike osx-mouse, the events are only emitted when the application is in focused. Even when the application is unfocused, move events are still generated when hovering over the application windows.

Usage

The module returns an event emitter instance.

var mouse = require('osx-mouse-cocoa')();

mouse.on('move', function(x, y) {
	console.log(x, y);
});

To stop tracking events, call mouse.destroy(). The mouse.ref() and mouse.unref() methods have been retained for API compatibility with osx-mouse, but they have no effect.

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.

About

Mouse tracking for macOS using Cocoa APIs

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C++ 56.6%
  • JavaScript 29.4%
  • C++ 9.8%
  • Python 4.2%