-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (31 loc) · 737 Bytes
/
index.js
File metadata and controls
33 lines (31 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const gkm = require('gkm');
const fs = require('fs');
const moment = require('moment');
function log(data) {
console.log(data);
fs.appendFile('log.txt', `${moment().format('YYYY-MM-DD HH:mm:ss')} ${data}\n`, (err) => {
if (err) throw err;
});
}
gkm.events.on('mouse.*', data => {
const btn = data[0];
switch (btn) {
case "1":
log('Left click');
break;
case "2":
log('Right click');
break;
case "3":
log('Middle click');
break;
case "4":
log('Scroll up');
break;
case "5":
log('Scroll down');
break;
default:
log(btn);
}
})