Activate shortcuts only if possible

This commit is contained in:
Arne Keller 2021-03-07 11:14:08 +01:00
parent 05885a4e6e
commit c22c125b7b

View File

@ -4,22 +4,26 @@ function handleKey(e) {
if (e.target.tagName.toLowerCase() === "vaadin-text-field") { if (e.target.tagName.toLowerCase() === "vaadin-text-field") {
return; return;
} }
let element = null;
if (e.keyCode === 37) { if (e.keyCode === 37) {
// left arrow // left arrow
if (!e.ctrlKey) { if (!e.ctrlKey) {
document.getElementById("previous-step").click(); element = document.getElementById("previous-step");
} else { } else {
document.getElementById("first-step").click(); element = document.getElementById("first-step");
} }
} else if (e.keyCode === 39) { } else if (e.keyCode === 39) {
// right arrow // right arrow
if (!e.ctrlKey) { if (!e.ctrlKey) {
document.getElementById("next-step").click(); element = document.getElementById("next-step");
} else { } else {
document.getElementById("last-step").click(); element = document.getElementById("last-step");
} }
} else if (e.key === "/") { } else if (e.key === "/") {
document.getElementById("inputField").focus(); document.getElementById("inputField").focus();
e.preventDefault(); e.preventDefault();
} }
if (element !== null) {
element.click();
}
} }