<html>
<head>
<script>

document.onkeydown = my_get_key;

var key;
var ransuu;
var alphabet = [
	"a","b","c","d","e",
	"f","g","h","i","j",
	"k","l","m","n","o",
	"p","q","r","s","t",
	"u","v","w","x","y",
	"z"
];

var count;

function my_init(){
	count = 10;
	my_mondai();
}

function my_get_key(){
	key = event.keyCode;

	if(key == (ransuu + 65)){
		alert("正解");
	}
	else{
		alert("不正解");
	}

	count--;

	if(count == 0){
		document.write("<p>おしまい!</p>");
	}
	else{
		my_mondai();
	}

}

function my_mondai(){
	ransuu = Math.floor(Math.random() * 26);
	document.getElementById("mondai_block").innerHTML = "<p>[" + alphabet[ransuu] + "]</p>";
	document.getElementById("count_block").innerHTML = "<p>残り" + count + "問</p>";
}

</script>
<title>タイピングゲーム</title>
</head>
<body onload="my_init()">
<p>タイピングゲーム</p>
<p>出てきた文字を入力してね!</p>
<div id="mondai_block"></div>
<div id="count_block"></div>
</body>
</html>