From a898224d3d8c69cb65bcf75041dbdf4e4f59e205 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sat, 16 Jan 2021 20:23:46 +0100 Subject: [PATCH] Switch to KeyboardEvent.code rather than KeyboardEvent.which, which is deprecated --- qt/aqt/data/web/js/editor.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qt/aqt/data/web/js/editor.ts b/qt/aqt/data/web/js/editor.ts index d56b71071..079a1135c 100644 --- a/qt/aqt/data/web/js/editor.ts +++ b/qt/aqt/data/web/js/editor.ts @@ -50,13 +50,13 @@ interface Selection { function onKey(evt: KeyboardEvent) { // esc clears focus, allowing dialog to close - if (evt.which === 27) { + if (evt.code === "Escape") { currentField.blur(); return; } // prefer
instead of
- if (evt.which === 13 && !inListItem()) { + if (evt.code === "Enter" && !inListItem()) { evt.preventDefault(); document.execCommand("insertLineBreak"); return; @@ -73,11 +73,11 @@ function onKey(evt: KeyboardEvent) { if (evt.shiftKey) { alter = "extend"; } - if (evt.which === 39) { + if (evt.code === "ArrowRight") { selection.modify(alter, "right", granularity); evt.preventDefault(); return; - } else if (evt.which === 37) { + } else if (evt.code === "ArrowLeft") { selection.modify(alter, "left", granularity); evt.preventDefault(); return; @@ -89,7 +89,7 @@ function onKey(evt: KeyboardEvent) { function onKeyUp(evt: KeyboardEvent) { // Avoid div element on remove - if (evt.which === 8 || evt.which === 13) { + if (evt.code === "Enter" || evt.code === "Backspace") { const anchor = window.getSelection().anchorNode; if (