diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 43eaa19a9..ded10b2d2 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -824,15 +824,6 @@ $(document).keydown(async (event) => { return; } - if (TestInput.spacingDebug) { - console.log( - "spacing debug", - "keypress", - event.key, - "length", - TestInput.keypressTimings.spacing.array.length - ); - } TestInput.setKeypressNotAfk(); //blocking firefox from going back in history with backspace diff --git a/frontend/src/ts/test/test-input.ts b/frontend/src/ts/test/test-input.ts index 9bc9cdc8a..aa0381f4c 100644 --- a/frontend/src/ts/test/test-input.ts +++ b/frontend/src/ts/test/test-input.ts @@ -322,14 +322,36 @@ export function recordKeyupTime(key: string): void { } export function recordKeydownTime(key: string): void { - if (!keysToTrack.includes(key)) return; + if (!keysToTrack.includes(key)) { + if (spacingDebug) { + console.log( + "spacing debug", + "key not tracked", + key, + "spacing array", + keypressTimings.spacing.array.length + ); + } + return; + } if (key === "Android") { key = "Android" + androidIndex; androidIndex++; } - if (keyDownData[key] !== undefined) return; + if (keyDownData[key] !== undefined) { + if (spacingDebug) { + console.log( + "spacing debug", + "key already down", + key, + "spacing array", + keypressTimings.spacing.array.length + ); + } + return; + } const now = performance.now(); @@ -348,8 +370,8 @@ export function recordKeydownTime(key: string): void { console.log( "spacing debug", "recorded", - "key", - "length", + key, + "spacing array", keypressTimings.spacing.array.length, "val", roundTo2(diff) @@ -359,6 +381,9 @@ export function recordKeydownTime(key: string): void { keypressTimings.spacing.last = now; if (keypressTimings.spacing.first === -1) { keypressTimings.spacing.first = now; + if (spacingDebug) { + console.log("spacing debug", "saved first", now); + } } } @@ -393,7 +418,12 @@ export function resetKeypressTimings(): void { }; keyDownData = {}; androidIndex = 0; - if (spacingDebug) console.clear(); + if (spacingDebug) { + console.clear(); + if (spacingDebug) { + console.log("spacing debug", "reset keypress timings"); + } + } } export function pushMissedWord(word: string): void { @@ -448,4 +478,7 @@ export function restart(): void { array: [], }, }; + if (spacingDebug) { + console.log("spacing debug", "restart"); + } }