shortcuts menu

This commit is contained in:
Devaev Maxim
2018-07-26 13:17:29 +03:00
parent d1a66cb948
commit c75d5e5352
2 changed files with 38 additions and 0 deletions

View File

@@ -6,6 +6,23 @@ var hid = new function() {
mouse.init();
}
this.emitShortcut = function(...codes) {
console.log(codes);
var delay = 0;
[[codes, true], [codes.slice().reverse(), false]].forEach(function(op) {
var [op_codes, state] = op;
op_codes.forEach(function(code) {
setTimeout(function() {
document.dispatchEvent(new KeyboardEvent(
(state ? "keydown" : "keyup"),
{code: code},
));
}, delay);
delay += 100;
});
});
};
this.installCapture = function(ws) {
var http = tools.makeRequest("GET", "/kvmd/hid", function() {
if (http.readyState === 4) {