<script language="JavaScript">
function handleKey() {
    if (window.event.keyCode == 27) {
        window.close();
    }
    if (window.event.keyCode == 13) {
        if (window.event.srcElement.name == "text1") {
            document.formname.text2.focus();
        }
        if (window.event.srcElement.name == "text2") {
            document.formname.text3.focus();
        }
        if (window.event.srcElement.name == "text3") {
            document.formname.text4.focus();
        }
        if (window.event.srcElement.name == "text4") {
            document.formname.button1.focus();
        }
        window.event.returnValue = false;
    }
}
</script>
<body onkeypress="handleKey()" onload="document.formname.text1.focus()">
    <form name="formname">
        <input type="text" name="text1"><br>
        <input type="text" name="text2"><br>
        <input type="text" name="text3"><br>
        <input type="text" name="text4"><br>
        <input type="button" name="button1">
    </form>
敲回车键试试
</body>