From 0d439bd7c4e7eba266b485d789d84a7b3b906825 Mon Sep 17 00:00:00 2001 From: Brandon Stull Date: Mon, 31 Jul 2023 13:16:57 -0400 Subject: [PATCH] #2 Fixed screen reader keyboard instructions to refer to the correct key for reading out the entire paragraph. Adjusted the control+Enter listener's behavior to dynamically build the entire paragraph and substitute the current input values where applicable. --- src/player-events.coffee | 16 +++++++++++++++- src/player.coffee | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/player-events.coffee b/src/player-events.coffee index 6c66639..1fbaf5d 100644 --- a/src/player-events.coffee +++ b/src/player-events.coffee @@ -68,7 +68,21 @@ Namespace('Wordguess').Events = do -> if e.ctrlKey and e.code == 'Enter' e.preventDefault() e.stopPropagation() - document.getElementById('aria-live').innerHTML = 'Now reading entire paragraph: ' + paragraph + + live = paragraph.split(';BLANK;') + inputs = gameParagraph.getElementsByTagName('input') + + final = [] + for i in [0..live.length - 1] + final.push(live[i]) + if i < live.length - 1 + if inputs[i].value != '' + final.push inputs[i].value + else + final.push ';BLANK;' + final = final.join('') + + document.getElementById('aria-live').innerHTML = 'Now reading entire paragraph: ' + final if e.ctrlKey and e.code == 'Space' e.preventDefault() e.stopPropagation() diff --git a/src/player.coffee b/src/player.coffee index a2706da..cbae959 100644 --- a/src/player.coffee +++ b/src/player.coffee @@ -38,7 +38,7 @@ Namespace('Wordguess').Engine = do -> '. You will be presented a paragraph with some words left blank. ' + 'Fill in the missing blanks with the words you think belong. ' + 'Use the Tab key to move between blank words. ' + - 'Hold the Control key and press Escape to hear the entire paragraph along with the blanks. ' + + 'Hold the Control key and press Enter or Return to hear the entire paragraph along with any unfilled blanks. ' + 'Hold the Control key and press Space to hear these instructions again. ' 'Click or press any key to begin.'