This article illustrates the method of JS to implement the form of the keyboard enter key. Share to everyone for your reference. The implementation methods are as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24-25 |
Perform keyboard key command function KeyDown (e) {var keycode = 0;//ie browser if (Checkbrowserisie ()) {keycode = Event.keycode;} else{//Firefox browser keycode = E.which} if (keycode = = 13)//Enter key is {//document.getelementbyid ("login"). Click (); document.get Elementbyid ("LoginForm"). Submit (); }//Determine if the visitor's browser is IE function Checkbrowserisie () {var result = false; var browser = navigator.appname; if (browser = = "MICR Osoft Internet Explorer ") {result = true; } |
Finally, just add in the body:.
Or the following methods, but in Firefox browser is not compatible:
?
1 2 3 4 |
function Document.onkeydown () {if (event.keycode==13) document.getElementById (' Loginfrom '). Submit (); |
I hope this article will help you with your JavaScript programming.