Please indicate the source of the original reprint: http://agilestyle.iteye.com/blog/2381878
Write JS scripts
function enterDown(e){ var keycode = 0; if(isFirefox()) { keycode = e.which; } else { keycode = e.keyCode; } if (keycode === 13 ) { //Enter key is 13 if(googleFlag) { loginWithGoogle(); // requires google to verify login } else { loginWithoutGoogle(); // does not require google to verify login } } } function isFirefox(){ if (navigator.userAgent.indexOf("Firefox") > -1) { return true; } else { return false; } }
Just import the script you wrote in the body tag
<body onkeydown="enterDown(event);">
Note:
Tested under Chrome, Firefox, and IE