Build a Typing Speed Test App (Source Code)
Test your WPM (Words Per Minute) in 60 seconds with live accuracy checking and word highlighting.
A typing test involves breaking a long string into a span array, tracking the userβs hidden textarea input, and comparing character by character!
Character Checking
JAVASCRIPT CODE
const quote = "The quick brown fox jumps over the lazy dog";
const chars = quote.split('').map(c => `${c}`);
display.innerHTML = chars.join('');
inputField.addEventListener('input', () => {
const arrayQuote = display.querySelectorAll('span');
const arrayValue = inputField.value.split('');
arrayQuote.forEach((characterSpan, index) => {
const character = arrayValue[index];
if (character == null) {
characterSpan.className = '';
} else if (character === characterSpan.innerText) {
characterSpan.className = 'correct';
} else {
characterSpan.className = 'incorrect';
}
});
});See the Live Demo to see how we calculate the WPM and handle the timer!