release keys when window loosing focus

This commit is contained in:
Devaev Maxim
2018-07-27 11:29:44 +03:00
parent b7d933b6ce
commit d2da0829b9
3 changed files with 40 additions and 2 deletions

View File

@@ -24,13 +24,17 @@ var keyboard = new function() {
};
this.setSocket = function(ws) {
keyboard.releaseAll();
__ws = ws;
$("hid-keyboard-led").className = (ws ? "led-on" : "led-off");
};
this.releaseAll = function(ws) {
__keys.concat(__modifiers).forEach(function(el_key) {
if (__isActive(el_key)) {
keyboard.fireEvent(el_key.id, false);
}
});
__ws = ws;
$("hid-keyboard-led").className = (ws ? "led-on" : "led-off");
};
this.fireEvent = function(code, state) {