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

后端 未结 4 574
离开以前
离开以前 2021-02-09 03:58

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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-09 04:49

    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
    };
    

提交回复
热议问题