diff --git a/src/media/experimental_assets/_ug-interactive_map_init.js b/src/media/experimental_assets/_ug-interactive_map_init.js index 32d48b53..0cf8f320 100644 --- a/src/media/experimental_assets/_ug-interactive_map_init.js +++ b/src/media/experimental_assets/_ug-interactive_map_init.js @@ -1,3 +1,8 @@ +/** + * Interactive map initialization logic declaration. + * Note that due to Anki Desktop web view being persistent + * for card reviews IIFE is used to separate the namespaces + */ (function () { const mapConfig = getMapConfig(); const commonConfig = mapConfig.commonConfig; @@ -165,10 +170,20 @@ if (typeof AnkiDroidJS !== "undefined") { showAnswer(); } else { - commonElements.hiddenTextarea.dispatchEvent(new KeyboardEvent("keypress", {code: "Enter"})); + dispatchEnterEvent() } } + /** + * Trigger "Enter" key press event. Note that Anki < 24.06 + * uses `code` property and Anki >= 24.06 - `key` property + * to query pressed key, so both properties must be present + */ + function dispatchEnterEvent() { + let artificialEvent = new KeyboardEvent("keypress", {code: "Enter", key: "Enter"}); + commonElements.hiddenTextarea.dispatchEvent(artificialEvent); + } + /** * Retrieve region highlighting color for answer card side * depending on the configuration and whether the selected