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:
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 is
{
//document.getelementbyid ("Login"). Click ();
document.getElementById ("LoginForm"). Submit ();
Determine if the visitor's browser is IE
function Checkbrowserisie () {
var result = false;
var browser = navigator.appname;
if (browser = = "Microsoft Internet Explorer") {result
= true;
}
return result;
}
Finally only need to add in the body: <body onkeydown= "KeyDown (event);" >.
Or the following methods, but in Firefox browser is not compatible:
function Document.onkeydown () {
if (event.keycode==13)
document.getElementById (' Loginfrom '). Submit ();
I hope this article will help you with your JavaScript programming.