按回车键,焦点切换到下一个文本框。为什么实现不了?如何修改能实现?

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>enter_to_next</title>
</head>
<body>
    <form action="" name="form1">
        username: <input type="text" name="username" id="" onkeypress="myEnter(form1.password)"><br>
        password: <input type="password" name="password" id="" onkeypress="myEnter(form1.tel)"><br>
        tel:  <input type="text" name="tel" id="" onkeypress="myEnter(form1.submit)"><br>
        <input type="reset"><br>
        <input type="submit" name="submit"><br>
    </form>
    <script>
        /* 按回车键,焦点切换到下一个文本框。 */
        function myEnter(str){
            if(event.keyCode==13)
                str.focus();
        }
    </script>
</body>
</html>

 

你按的是回车,我出发的是tab