cursor-info

0.2.1 • Public • Published

cursor-info

npm version

Retrieves an information about global cursor in your system, needs Java (1.5 minimum) installed

Install

npm install --save cursor-info

Usage

// this will start listening for mouse movements automatically.
// NOTE: your app won't terminate while cursor is listening for 
// mouse movements. In order for your app to terminate you should
// manually stop listening. To find out how to do that
// read on
var cursor = require("cursor-info");
 
cursor.on("mousemove", (data) => {
  console.log("X position:", data.x, "Y position:", data.y);  
});
 
cursor.on("error", (error) => {
  throw new Error(error);
});

You can manually control when to start and stop listening for mouse movements

// to prevent cursor from automatically starting listening for mouse 
// movements you can invoke stopWatchig() method after you require 
// cursor object;
var cursor = require("cursor-info");
cursor.stopWatching();
 
// then you can start listening for mouse movements at any time in your
// application by invoking startWatching() method. startWatching() method 
// is cached, so, invoking it many times won't have any effect untill you 
// call stopWatching() method, after that the start/stopWatching() 
// cicle repeats
cursor.startWatching();
 
// now your app won't terminate until you manualy stop listening by invoking 
// stopWatching() method again;
cursor.on("mousemove", (data) => {
  console.log("X position:", data.x, "Y position:", data.y);  
});
 
cursor.on("error", (error) => {
  throw new Error(error);
});
 
cursor.stopWatching();
// terminating...

Package Sidebar

Install

npm i cursor-info

Weekly Downloads

1

Version

0.2.1

License

MIT

Last publish

Collaborators

  • dembel