I’m making a site where a user repeatedly clicks a button to increase his/her score. In order to prevent people cheating, I want to measure the amount of time between each click, and if they are clicking inhumanly fast and there is very little time between clicks, I want a CAPTCHA or something to come up.
How would I measure the time between clicks?
My suggestion would look like:
This will output & store the difference between two clicks in miliseconds. You could use the history array to get an average value and check if that is below 50ms or something.
Demo: http://jsfiddle.net/TxKjT/
Demo with average check: http://jsfiddle.net/TxKjT/2/