mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-22 16:26:18 +08:00
added fallback for no key location code (not just android)
should fix some of the result validation errors
This commit is contained in:
parent
c69d2d0251
commit
3e95164703
|
@ -993,9 +993,8 @@ $("#wordsInput").keydown((event) => {
|
|||
|
||||
const now = performance.now();
|
||||
setTimeout(() => {
|
||||
const isAndroid =
|
||||
event.key === "Unidentified" && event.code === "" && event.which === 229;
|
||||
TestInput.recordKeydownTime(now, isAndroid ? "Android" : event.code);
|
||||
const eventCode = event.code === "" ? "NoCode" : event.code;
|
||||
TestInput.recordKeydownTime(now, eventCode);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
|
@ -1010,11 +1009,12 @@ $("#wordsInput").keyup((event) => {
|
|||
event.code = "Space"; //powertoys bug
|
||||
}
|
||||
|
||||
event.code = "";
|
||||
|
||||
const now = performance.now();
|
||||
setTimeout(() => {
|
||||
const isAndroid =
|
||||
event.key === "Unidentified" && event.code === "" && event.which === 229;
|
||||
TestInput.recordKeyupTime(now, isAndroid ? "Android" : event.code);
|
||||
const eventCode = event.code === "" ? "NoCode" : event.code;
|
||||
TestInput.recordKeyupTime(now, eventCode);
|
||||
}, 0);
|
||||
});
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ const keysToTrack = [
|
|||
"Period",
|
||||
"Slash",
|
||||
"Space",
|
||||
"Android", //smells
|
||||
"NoCode", //android (smells) and some keyboards might send no location data - need to use this as a fallback
|
||||
];
|
||||
|
||||
interface Keypress {
|
||||
|
@ -318,14 +318,14 @@ export function forceKeyup(now: number): void {
|
|||
}
|
||||
}
|
||||
|
||||
let androidIndex = 0;
|
||||
let noCodeIndex = 0;
|
||||
|
||||
export function recordKeyupTime(now: number, key: string): void {
|
||||
if (!keysToTrack.includes(key)) return;
|
||||
|
||||
if (key === "Android") {
|
||||
androidIndex--;
|
||||
key = "Android" + androidIndex;
|
||||
if (key === "NoCode") {
|
||||
noCodeIndex--;
|
||||
key = "NoCode" + noCodeIndex;
|
||||
}
|
||||
|
||||
if (keyDownData[key] === undefined) return;
|
||||
|
@ -351,9 +351,9 @@ export function recordKeydownTime(now: number, key: string): void {
|
|||
return;
|
||||
}
|
||||
|
||||
if (key === "Android") {
|
||||
key = "Android" + androidIndex;
|
||||
androidIndex++;
|
||||
if (key === "NoCode") {
|
||||
key = "NoCode" + noCodeIndex;
|
||||
noCodeIndex++;
|
||||
}
|
||||
|
||||
if (keyDownData[key] !== undefined) {
|
||||
|
@ -431,7 +431,7 @@ export function resetKeypressTimings(): void {
|
|||
lastStartTime: -1,
|
||||
};
|
||||
keyDownData = {};
|
||||
androidIndex = 0;
|
||||
noCodeIndex = 0;
|
||||
if (spacingDebug) {
|
||||
console.clear();
|
||||
if (spacingDebug) {
|
||||
|
|
Loading…
Reference in a new issue