Here's some code for a slightly more advanced version of what you are looking for:
Code:
<html>
<head>
<title>Test</title>
<script language="JavaScript">
function getKey(keyStroke) {
var keyCode = (document.layers) ? keyStroke.which : event.keyCode;
// var keyString = String.fromCharCode(keyCode).toLowerCase();
if(keyCode == "13") {
alert("You Hit Enter");
} else {
alert("Wrong");
}
}
document.onkeypress=getKey;
</script>
</head>
<body>
</body>
</html>
Give it a shot to view the effects. Hitting enter triggers a function, i threw in an else statement so you can see what happens when you hit something else. I commented out keystring but you can use it if you want. It will equal whatever letter is pressed. You could use this for a million different things. I've seen people use it for site navigation, javascript games, the possibilities are vast. 13 is the keycode for enter, if you want to find out other keycodes(shift, alt, ctrl, etc...) then either google them or else set it to alert(keyCode) when you press a key and write down all of the keycodes you are interested in.