...

View Full Version : onkeydown enter



crays
06-07-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.

crays
06-08-2008, 01:32 PM
I think i got it


<SCRIPT>
if (document.layers)
document.captureEvents(Event.KEYDOWN);
document.onkeydown =
function (evt) {
var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) :
event.keyCode;
if (keyCode == 13) {
document.aForm.submit();
return false;
}
else
return true;
};

</SCRIPT>


but can someone explain how it functions? Please.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum