global-keys
Version:
A wrapper around keys.exe to get global keypress data.
33 lines (32 loc) • 1.48 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyStream = void 0;
var child_process = require("child_process");
var path = require("path");
var events_1 = require("events");
/** A stream of keystates */
var KeyStream = /** @class */ (function (_super) {
__extends(KeyStream, _super);
function KeyStream() {
var _this = _super.call(this) || this;
var keysProcess = child_process.spawn("" + path.join(__dirname, '../bin/keys.exe'));
keysProcess.stdout.on('data', function (data) { return _this.emit('data', JSON.parse(data)); });
keysProcess.on('close', function () { return _this.emit('error', new Error("unexpected closure of keys.exe process")); });
return _this;
}
return KeyStream;
}(events_1.EventEmitter));
exports.KeyStream = KeyStream;