WPM = ((Total Key Presses / 5) / Time in minute)
function CalculateWPM(keywords: number, time: number): number {
return Math.round(((keywords / 5) / time));
}
Acc = (False Key Presses / Total Key Presses) * 100
function CalculateAcc(WKeystrokes: number, TKeystrokes: number): number {
return Math.round((WKeystrokes / TKeystrokes) * 100);
}
AWPM = WPM * (ACC / 100)
function CalculateAWPM(WPM: number, Acc: number): number {
return Math.ceil(WPM * Acc);
}
You can train currently on 5 languages, but you can feel free to add you own language if you want :)
const wordArrays: WordArrays = {
FR: mots,
DE: worter,
ES: palabras,
KR: 단어,
EN: words
}
these words are in the file words.ts, where the 5 languages are exported
Using some simple algorithm:
- Take the list
- take the word you typed (the first one of the list) and remove it
- slide every word to -1
- add a new word at the end of the list
function to make the algorithm (1, 2, 3):
function wordLineGen(newWord: string): string[] {
wordlist.push(newWord);
for (let i: number = 0; i < wordlist.length; i++)
wordlist[i] = wordlist[i + 1];
wordlist.pop();
return wordlist;
}
to get a random word in the language you want (4):
function getRandomWord(): string {
const selectedArray: string[] = wordArrays[lang] || words;
const randomIndex: number = Math.floor(Math.random() * selectedArray.length);
return selectedArray[randomIndex];
}
see the full typescript code here