2021-03-10 17:39:41 +00:00
|
|
|
document.onkeydown = handleKey;
|
|
|
|
|
|
|
|
function handleKey(e: KeyboardEvent) {
|
|
|
|
if ((e.target! as HTMLElement).tagName.toLowerCase() === "vaadin-text-field") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let element = null;
|
|
|
|
if (e.code === "ArrowLeft") {
|
|
|
|
// left arrow
|
|
|
|
if (!e.ctrlKey) {
|
|
|
|
element = document.getElementById("previous-step");
|
|
|
|
} else {
|
|
|
|
element = document.getElementById("first-step");
|
|
|
|
}
|
|
|
|
} else if (e.code === "ArrowRight") {
|
|
|
|
// right arrow
|
|
|
|
if (!e.ctrlKey) {
|
|
|
|
element = document.getElementById("next-step");
|
|
|
|
} else {
|
|
|
|
element = document.getElementById("last-step");
|
|
|
|
}
|
|
|
|
} else if (e.key === "/") {
|
2021-07-05 07:28:03 +00:00
|
|
|
document.getElementById("term-input-field")!.focus();
|
2021-03-10 17:39:41 +00:00
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
if (element !== null) {
|
|
|
|
element.click();
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
}
|