From 5dfa95e6e13ec28a3552eb284e65f3f773cb09d4 Mon Sep 17 00:00:00 2001 From: Miodec Date: Wed, 13 Sep 2023 14:20:28 +0100 Subject: [PATCH] impr(typing): add reminder that opposite shift mode is on if incorrect shift was used too many times Closes #4626 --- frontend/src/ts/controllers/input-controller.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 05bcc9d94..7f5708906 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -38,6 +38,7 @@ let dontInsertSpace = false; let correctShiftUsed = true; let isKoCompiling = false; let isBackspace: boolean; +let incorrectShiftsInARow = 0; const wordsInput = document.getElementById("wordsInput") as HTMLInputElement; const koInputVisual = document.getElementById("koInputVisual") as HTMLElement; @@ -561,7 +562,20 @@ function handleChar( KeymapEvent.flash(char, thisCharCorrect); } - if (!correctShiftUsed && Config.difficulty !== "master") return; + if (Config.difficulty !== "master") { + if (!correctShiftUsed) { + incorrectShiftsInARow++; + if (incorrectShiftsInARow >= 5) { + Notifications.add("Reminder: Opposite shift mode is on.", 0, { + important: true, + }); + } + return; + } else { + incorrectShiftsInARow = 0; + console.log("correct shift used"); + } + } //update current corrected version. if its empty then add the current char. if its not then replace the last character with the currently pressed one / add it if (TestInput.corrected.current === "") {