web: option to remap ctrl/caps

This commit is contained in:
Maxim Devaev
2023-10-25 00:56:08 +03:00
parent 620b9fcc89
commit 3c611121a8
4 changed files with 33 additions and 4 deletions

View File

@@ -51,6 +51,8 @@ export function Keyboard(__recordWsEvent) {
window.addEventListener("focusin", __updateOnlineLeds);
window.addEventListener("focusout", __updateOnlineLeds);
tools.storage.bindSimpleSwitch($("hid-keyboard-swap-cc-switch"), "hid.keyboard.swap_cc", false);
};
/************************************************************************/
@@ -129,6 +131,13 @@ export function Keyboard(__recordWsEvent) {
var __sendKey = function(code, state) {
tools.debug("Keyboard: key", (state ? "pressed:" : "released:"), code);
if ($("hid-keyboard-swap-cc-switch").checked) {
if (code === "ControlLeft") {
code = "CapsLock";
} else if (code === "CapsLock") {
code = "ControlLeft";
}
}
let event = {
"event_type": "key",
"event": {"key": code, "state": state},