added deselect and select of checkbox by Enter key

This commit is contained in:
j264415 2024-02-20 11:07:10 +00:00
parent 61d587a4a5
commit 68a8d4328f
2 changed files with 22 additions and 0 deletions

View file

@ -51,6 +51,27 @@ class ControlsWaiter {
}
}
/**
* Handles the Auto Bake checkbox based on keyboard.
*
*/
keyboardCheckAutoBake() {
const autoBakeId = document.getElementById("auto-bake");
autoBakeId.addEventListener("keydown", this.autoBakeKeyboardHandler, false);
}
/**
* Checks or unchecks the Auto Bake checkbox with "Enter"
* @param {Event} ev
*/
autoBakeKeyboardHandler(ev) {
const checkBox = document.getElementById("auto-bake");
ev.preventDefault();
if (ev.key === "Enter" || ev.key === " ") {
checkBox.checked = !checkBox.checked;
}
}
/**
* Handler to trigger baking.