summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-07-26 13:17:29 +0300
committerDevaev Maxim <[email protected]>2018-07-26 13:41:03 +0300
commitc75d5e5352790fa413e5356304efd4396059d54d (patch)
tree6b562e1b5b73ef8c1891ca57b68a20b6738f0f8d
parentd1a66cb948d1868bcbf03b2b1e5cd4a425ed0afe (diff)
shortcuts menu
-rw-r--r--kvmd/web/index.html21
-rw-r--r--kvmd/web/js/hid.js17
2 files changed, 38 insertions, 0 deletions
diff --git a/kvmd/web/index.html b/kvmd/web/index.html
index 0846673f..752ecf4f 100644
--- a/kvmd/web/index.html
+++ b/kvmd/web/index.html
@@ -166,6 +166,27 @@
</div>
</div>
</li>
+
+ <li class="ctl-right-actions">
+ <div class="ctl-dropdown">
+ <a class="ctl-item" href="#">
+ Shortcuts &#8628;
+ </a>
+ <div class="ctl-dropdown-content" style="display:none">
+ <button onclick="hid.emitShortcut('ControlLeft', 'AltLeft', 'Delete');">&bull; Ctrl+Alt+Del</button>
+ <hr>
+ <button onclick="hid.emitShortcut('ControlLeft', 'Escape');">&bull; Ctrl+Esc</button>
+ <button onclick="hid.emitShortcut('AltLeft', 'Tab');">&bull; Alt+Tab</button>
+ <button onclick="hid.emitShortcut('AltLeft', 'Escape');">&bull; Alt+Escape</button>
+ <button onclick="hid.emitShortcut('AltLeft', 'Space');">&bull; Alt+Space</button>
+ <button onclick="hid.emitShortcut('AltLeft', 'Enter');">&bull; Alt+Enter</button>
+ <button onclick="hid.emitShortcut('AltLeft', 'F4');">&bull; Alt+F4</button>
+ <hr>
+ <button onclick="hid.emitShortcut('AltLeft', 'PrintScreen');">&bull; Alt+PrtSc</button>
+ <button onclick="hid.emitShortcut('PrintScreen');">&bull; PrtSc</button>
+ </div>
+ </div>
+ </li>
</ul>
<div class="window" style="left:50%; top:70px">
diff --git a/kvmd/web/js/hid.js b/kvmd/web/js/hid.js
index 2e5538da..93a980bb 100644
--- a/kvmd/web/js/hid.js
+++ b/kvmd/web/js/hid.js
@@ -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) {