How the WPM are calculated, as it makes more sense to go by CPM and just divide by average word length (5.1 characters in English).
What affects the WPM by changing it from the single textarea to any input using the :input selector from jQuery.
However, applying this to a website I’m tinkering with has no effect on the WPM counter.
The id of the div where the HTML updates the WPM counter is still stats. It either isn’t updating it or isn’t running the script at all. Not sure which, but inspecting the site shows the JS is loading correctly along with the jQuery libraries.
If I were you, I’d use the dev tools in your browser to make sure the event is firing and that the element you’re trying to add text to exists. console.log() is your friend
So, I’m using Laravel 5.4 Framework to produce this website. I’m not sure how I’d verify if it does use those standards, but this is in the code:
The scripts show like so in the final rendered HTML:
Going to those paths gives the corresponding javascript, so it’s definitely available.
Thanks, I’ll try this out and get the JS to update the log when it does things like register the key press and see if that is doing things even though the HTML isn’t updating yet.
Edit:
So I had it output a message to console.log when it did things like so:
$stats.html("WPM: " + calculateWpm(startTime, performance.now(), keyspressed));
console.log('calculateWpm is' + calculateWpm(startTime, performance.now(), keyspressed) + '.');
}
});
.appendTo('.js_submit'); // appends attributes to js_submit class element.
console.log('Submit occurred. WPM is: ' + wpm + '.');
return true; // Unsure if this is necessary?
However, nothing is appearing in the console log. When I try to manually run the function calculateWpm, it returns NaN. Running the function with values returns the correct math done. So calculateWpm(1000, 2000, 100) -> “6000.00”). Which is saying “pressing 100 keys in one second is typing at 6000 WPM.” So it is loading the JS at least.
I tried both clicking the submit button and typing. So it’s either not seeing those events even though the JS is loading, or there’s an error somewhere and the inspector isn’t listing it?