View Full Version : onkeydown enter

Jun 7th, 2008, 05:36 PM
Hi, i'm trying to do this. When enter is clicked, the image with the specific javascript will function. Its basically a login page but with image as a button. I used <img src="blah.jpg" onclick="login()"> and the login() javascript is document.login.submit(); Now as we all login, we always click the enter button after typing our usernames and password, i would like to know how do i use javascript to do so. Can someone direct me? I've tried searching google but they only show example on something else like in w3schools, they only show how to deny the numbers character with the onkeydown event. There is only 1 example. Can someone guide me? Thanks.

Jun 8th, 2008, 01:32 PM
I think i got it

if (document.layers)
document.onkeydown =
function (evt) {
var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) :
if (keyCode == 13) {
return false;
return true;


but can someone explain how it functions? Please.