How can you display Typing Speed using Javascript or the jQuery library?

后端 未结 4 1499
-上瘾入骨i
-上瘾入骨i 2021-02-09 04:26

I would like to add a typing speed indicator just below the textarea we use on our contact form. It is just for fun and to give the user some interactivity with the page while t

4条回答
  •  醉酒成梦
    2021-02-09 04:40

    a horribly simple, untested implementation:

    var lastrun = new Date();
    textarea.onkeyup = function() {
        var words = textarea.value.split(' ');
        var minutes_since_last_check = somefunctiontogetminutesdifference(new Date(), lastrun);
        var wpm = (words.length-1)/minutes_since_last_check;
        //show the wpm in a div or something
    };
    

提交回复
热议问题