diff options
author | Devaev Maxim <[email protected]> | 2018-07-25 10:34:44 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-07-25 10:34:44 +0300 |
commit | 922e303c7045e2b1da8116611e53efb8e8d77e08 (patch) | |
tree | 68d98aa1504a69d548a431073a9763f2a67fbb56 /kvmd/web/js/keyboard.js | |
parent | 22c060956e37a9cb1733a3e7f808048779a5a72a (diff) |
virtual keyboard prototype
Diffstat (limited to 'kvmd/web/js/keyboard.js')
-rw-r--r-- | kvmd/web/js/keyboard.js | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/kvmd/web/js/keyboard.js b/kvmd/web/js/keyboard.js index 4f1ade8b..798b9192 100644 --- a/kvmd/web/js/keyboard.js +++ b/kvmd/web/js/keyboard.js @@ -16,12 +16,24 @@ var keyboard = new function() { var __keyHandler = function(ws, event, state) { // https://github.com/wesbos/keycodes/blob/gh-pages/scripts.js - tools.debug("Key", (state ? "pressed:" : "released:"), event) - event.preventDefault(); - ws.send(JSON.stringify({ - event_type: "key", - key: event.code, - state: state, - })); + el_key = $(event.code); + if (el_key) { + tools.debug("Key", (state ? "pressed:" : "released:"), event); + + if (state) { + el_key.style.boxShadow = "none"; + el_key.style.color = "var(--fg-color-selected)"; + el_key.style.backgroundColor = "var(--bg-color-dark)"; + } else { + el_key.removeAttribute("style"); + } + + event.preventDefault(); + ws.send(JSON.stringify({ + event_type: "key", + key: event.code, + state: state, + })); + } }; }; |