タイピング測定

タイピング速度を測定するプログラムをつくってみた。
http://jsdo.it/katona/typing

上段のtextareaの課題文を下段のtextareaに入力する。
1文字目の打ち始めから計測を開始するやや有利(?)な仕様。

<html>
<head>
<title>Typing</title>
<script>
function key(f){
  while(f.src.value.indexOf(f.usr.value)!=0) f.usr.value = f.usr.value.slice(0,-1);
  if(f.now.value.match(/GOAL/)) return;
  if(f.start.value=="") f.start.value = new Date().getTime();
  f.now.value = (new Date().getTime() - f.start.value) / 1000;
  if(f.usr.value==f.src.value) f.now.value += ' GOAL';
}
</script>
</head>
<body onload='document.f.usr.focus()'>
<form name=f>
<input name=now><input type=reset><input name=start style='display:none'><br>
<textarea name=src rows=3 style='width:100%'>The razor-toothed piranhas of the genera Serrasalmus and Pygocentrus are the most ferocious freshwater fish in the world. In reality they seldom attack a human.</textarea>
<textarea name=usr rows=3 style='width:100%' onkeyup='key(document.f)'></textarea>
</form>
</body>
</html>

サンプルの課題文はこれと同じもの

ケータイ早打ちの世界最速記録更新、iPhoneで達成 - スラッシュドット・ジャパン
課題文は以下の通り。ギネス認定を受けるための標準テキストになっている。
The razor-toothed piranhas of the genera Serrasalmus and Pygocentrus are the most ferocious freshwater fish in the world. In reality they seldom attack a human.
それまでの最速は、SamsungGalaxy Sを使ってイギリスの女性が23日に達成した25.94秒だった。ブライアンさんはiPhoneを使って21.8秒で入力したという。

http://slashdot.jp/mobile/article.pl?sid=10/08/30/0811226

しかし、PCのキーボードでやってみても、30秒台しかでない…
携帯のOpera mobileでは、いったんフォーカスしてテキスト入力状態になると、入力を確定してフォーカスを解除するまでonkeyupのイベントが発生しないようだ。
そんな状況下、携帯では2タッチ入力で200秒超だった…