From c275a7fa370917d1dbecdbad471e96b4065022a3 Mon Sep 17 00:00:00 2001 From: Oliver Tacke Date: Mon, 8 Jul 2024 12:44:38 +0200 Subject: [PATCH] Add key listener workaround for Firefox --- src/scripts/h5p-crossword-input.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scripts/h5p-crossword-input.js b/src/scripts/h5p-crossword-input.js index 898358b..4f3a87f 100644 --- a/src/scripts/h5p-crossword-input.js +++ b/src/scripts/h5p-crossword-input.js @@ -204,6 +204,8 @@ export default class CrosswordInput { } const start = inputField.selectionStart; + console.log(event.key, inputField.value, start); + inputField.value = `${inputField.value.substr(0, start + 1)}${inputField.value.substr(start + 1)}`; inputField.selectionEnd = start + 1; @@ -231,7 +233,7 @@ export default class CrosswordInput { text: after, readOffset: -1 // don't read }); - }, 0); // selectionStart will be 0 before DOM rendered + }, 25); // selectionStart will be 0 before DOM rendered }, false); // Only update table if input is valid or using arrow keys