user macro

This commit is contained in:
Devaev Maxim
2020-06-20 11:29:06 +03:00
parent 490e5b352e
commit cf2f763d1b
8 changed files with 341 additions and 21 deletions

View File

@@ -24,11 +24,13 @@ import {tools, $, $$$} from "../tools.js";
import {Keypad} from "../keypad.js";
export function Keyboard() {
export function Keyboard(record_callback) {
var self = this;
/************************************************************************/
var __record_callback = record_callback;
var __ws = null;
var __online = true;
@@ -136,12 +138,14 @@ export function Keyboard() {
var __sendKey = function(code, state) {
tools.debug("Keyboard: key", (state ? "pressed:" : "released:"), code);
let event = {
"event_type": "key",
"event": {"key": code, "state": state},
};
if (__ws) {
__ws.send(JSON.stringify({
"event_type": "key",
"event": {"key": code, "state": state},
}));
__ws.send(JSON.stringify(event));
}
__record_callback(event);
};
__init__();