Skip to content

Instantly share code, notes, and snippets.

@thib3113
Last active September 25, 2018 16:30
Show Gist options
  • Save thib3113/60642c09e9a3811e135f to your computer and use it in GitHub Desktop.
Save thib3113/60642c09e9a3811e135f to your computer and use it in GitHub Desktop.
http://typing-speed-test.aoeu.eu/ => type fast as your computer can ( copy paste in your console )
number_words = $("#words span").length;
var start = Date.now();
$("#words span").each(function(){
text = $(this).text()+" ";
for (var i = 0; i < text.length; i++) {
code = text.charCodeAt(i);
var e = $.Event("keydown", { keyCode: code});
var _e = $.Event("keyup", { keyCode: code});
$("#input").val($("#input").val()+text[i]);
$speedtest.keydown($("#input").get(0), e)
$speedtest.keypress($("#input").get(0), _e);
};
})
var end = Date.now();
var allTime = end - start;
console.log(number_words+" word"+(number_words>1?"s":"")+" in "+number_words/100+"seconds");
@vankasteelj
Copy link

Even faster (~+30% on FF, ~+100% on Chrome).

var text = $speedtest.words.join(' ') + ' ', code;
for (var j = 0; j < text.length; j++) {
    code = text[j];
    var e = $.Event("keydown", { keyCode: code});
    var _e = $.Event("keyup", { keyCode: code});
    $("#input").val($("#input").val() + code);
    $speedtest.keydown($("#input").get(0), e)
    $speedtest.keypress($("#input").get(0), _e);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment