mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-20 23:36:37 +08:00
fixed the key spacing data not making sense error
This commit is contained in:
parent
be4e5dc20c
commit
cbd163a889
|
@ -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();
|
||||
|
|
|
@ -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: [],
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue