0.2.1 • Published 8 years ago

cursor-info v0.2.1

Weekly downloads
1
License
MIT
Repository
-
Last release
8 years ago

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...
0.2.1

8 years ago

0.2.0

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago