mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-26 00:25:43 +08:00
better spacing debug
This commit is contained in:
parent
09bb9d5687
commit
7bffb095b7
2 changed files with 38 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue