Alsvha
October 3rd, 2005, 08:51 AM
Hiya all.
Suppose I have a hyperlink. If this gets focus and I press enter, I'd like to capture that enter event and do some stuff, this I'd think would be simple ... but nooooo :D
I have a link where I've set the onKeyPress event on which calls a function (simplified):
function trapEnterNote(intID, e)
{
var keycode;
if (window.event) keycode = window.event.keycode;
else if (e) keycode = e.which;
else return true
alert(keycode);
return false;
}
This function gets trigger well enough - which means that the onKeyPress works. However - when I try to alert the keycode I get "undefined" in IE and "0" in FireFox.
The excat same code works with input=text fields which leads me to belive that I can't get the keycode from onKeyPressed used on a hyperlink at all.
Is this a correct assumption or am I doing something wrong?
Regards.
Suppose I have a hyperlink. If this gets focus and I press enter, I'd like to capture that enter event and do some stuff, this I'd think would be simple ... but nooooo :D
I have a link where I've set the onKeyPress event on which calls a function (simplified):
function trapEnterNote(intID, e)
{
var keycode;
if (window.event) keycode = window.event.keycode;
else if (e) keycode = e.which;
else return true
alert(keycode);
return false;
}
This function gets trigger well enough - which means that the onKeyPress works. However - when I try to alert the keycode I get "undefined" in IE and "0" in FireFox.
The excat same code works with input=text fields which leads me to belive that I can't get the keycode from onKeyPressed used on a hyperlink at all.
Is this a correct assumption or am I doing something wrong?
Regards.