X
Xandax
Hiya all.
I'm trying to capture which key is pressed when a hyperlink is active,
which I'd thought would be simpel.
However - IE returns undefined and FireFox returns 0 when I try to
alert the keycode value, which means the event fires, but I apparently
can't get the keycode which strikes me as odd.
The code I use looks something like this (simplified):
<a href="somelink" onkeypress="return trapEnterNote(1, event)"><img
src="someimage"></a>
Then in my function I do this:
function trapEnterNote(intID, e)
{
var keycode;
if (window.event) keycode = window.event.keycode;
else if (e) keycode = e.which;
else return true
alert(keycode);
if (keycode == 13)
{
function trapEnterNote(intID, e)
{
alert('Whiskey Tango Foxtrot');
var keycode;
if (window.event) keycode = window.event.keycode;
else if (e) keycode = e.which;
else return true
alert(keycode);
return false;
}
This returns "undefined" and 0 as mentioned in the "alert(keycode);".
Is it not possible to get which key was pressed on a hyperlink, is it
only for input fields? Or is it me that does something wrong, and if so
.... any hints/help?
Regards
Xandax
I'm trying to capture which key is pressed when a hyperlink is active,
which I'd thought would be simpel.
However - IE returns undefined and FireFox returns 0 when I try to
alert the keycode value, which means the event fires, but I apparently
can't get the keycode which strikes me as odd.
The code I use looks something like this (simplified):
<a href="somelink" onkeypress="return trapEnterNote(1, event)"><img
src="someimage"></a>
Then in my function I do this:
function trapEnterNote(intID, e)
{
var keycode;
if (window.event) keycode = window.event.keycode;
else if (e) keycode = e.which;
else return true
alert(keycode);
if (keycode == 13)
{
function trapEnterNote(intID, e)
{
alert('Whiskey Tango Foxtrot');
var keycode;
if (window.event) keycode = window.event.keycode;
else if (e) keycode = e.which;
else return true
alert(keycode);
return false;
}
This returns "undefined" and 0 as mentioned in the "alert(keycode);".
Is it not possible to get which key was pressed on a hyperlink, is it
only for input fields? Or is it me that does something wrong, and if so
.... any hints/help?
Regards
Xandax