Very simple code, here are two methods for you,
The first type:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Check Score</title> <mce:script language="JavaScript"><!-- function keyLogin(){ if (event.keyCode==13) //The key value of the Enter key is 13 document.getElementById("input1").click(); //Login event calling the login button} // --></mce:script> </head> <body onkeydown="keyLogin();"> <input type="text" /> <input type="text" /> <input type="text" /><input type="text" /> <input type="text" /><input type="text" /> <input type="text" /><input type="text" /> <!--<input id="input1" value="login" type="button" onclick="alert('Called successfully!')">--> <img id="input1" onclick="alert('Called successfully!')"/> </body> </html>The second type:
<script>function KeyDown(){ if (event.keyCode == 13) { event.returnValue=false; event.cancel = true; Form1.btnsubmit.click(); }}</script>Usage method: <form name="Form1" method="">Username:<INPUT TYPE=text SIZE=20 maxlength = 8 onkeydown=KeyDown()>Password:<INPUT TYPE=password SIZE=20 maxlength = 8 onkeydown=KeyDown()><input type="submit" name="btnsubmit" value="submit" /></form>The above two ways to log in to js on the front end of the web page to press Enter to achieve login are all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.