var str = 'Foo bar is not equal to bar foo.' ;
var alphabet = 'abcdefghijklmnopqrstuvwxyz' ;
var pos = 0 ;
var tmpStr = '' ;
var doBackspace = false ;
function startTyping (str) {
if(doBackspace) {
tmpStr = tmpStr.slice(0,tmpStr.length-1);
doBackspace = false ;
} else {
if(Math.ceil((Math.random()*100)) < 80) {
tmpStr += str[pos] ;
pos++ ;
} else {
tmpStr += alphabet[Math.floor(Math.random()*(alphabet.length))] ;
doBackspace = true ;
}
}
$('body').html(tmpStr) ;
if(pos < str.length) {
setTimeout(function(){
startTyping(str)
}, 300) ;
}
}
$(document).ready(function(){
startTyping(str) ;
});
Can change interval 300 to higher value to reduce typing speed, also add characters to alphabet to increase number of possible mistaken chars, 80 to lower value to increase chance for a mistake