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

@ -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">

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) {