fixed the key spacing data not making sense error

This commit is contained in:
Miodec 2021-03-14 21:10:29 +00:00
parent be4e5dc20c
commit cbd163a889
2 changed files with 14 additions and 10 deletions

View file

@ -1554,6 +1554,8 @@ function showResult(difficultyFailed = false) {
correctedHistory.push(currentCorrected);
}
TestStats.recordKeypressSpacing();
resultCalculating = true;
resultVisible = true;
TestStats.setEnd(performance.now());
@ -4600,14 +4602,7 @@ $(document).keydown(function (event) {
if (!(event.key == " ") && !event.originalEvent.isTrusted) return;
if (!resultVisible) {
let now = performance.now();
let diff = Math.abs(TestStats.keypressTimings.spacing.current - now);
if (TestStats.keypressTimings.spacing.current !== -1) {
TestStats.pushKeypressSpacing(diff);
// keypressStats.spacing.array.push(diff);
}
TestStats.setKeypressSpacing(now);
// keypressStats.spacing.current = now;
TestStats.recordKeypressSpacing();
}
Monkey.type();

View file

@ -176,6 +176,15 @@ export function pushKeypressSpacing(val) {
keypressTimings.spacing.array.push(val);
}
export function recordKeypressSpacing() {
let now = performance.now();
let diff = Math.abs(keypressTimings.spacing.current - now);
if (keypressTimings.spacing.current !== -1) {
pushKeypressSpacing(diff);
}
setKeypressSpacing(now);
}
export function setKeypressSpacing(val) {
keypressTimings.spacing.current = val;
}
@ -183,11 +192,11 @@ export function setKeypressSpacing(val) {
export function resetKeypressTimings() {
keypressTimings = {
spacing: {
current: -1,
current: performance.now(),
array: [],
},
duration: {
current: -1,
current: performance.now(),
array: [],
},
};