I have a follow up question about the code that I am trying to produce.
So what I would like to do is:
Mouse goes over a link and then determines which key is pressed.
This seems to be ok with the following code:
function checkKeycode(e) {
document.onkeydown = checkKeycode
var keycode
if (window.event)
keycode = window.event.keyCode;
else if (e)
keycode = e.which;
switch (keycode) {
case 65:
alert("keycode: " + keycode);
break;
case 68:
alert("keycode: " + keycode);
break;
}
}
and this is one of the links:
<a href="link" onmouseout="document.onkeydown = null" onmouseover="checkKeycode()">text</a>
But now I want to be able to do some additional things according to which key is pressed.
For example somebody moves over the link and presses a and then an item is added to a shopping cart. Or he presses d and an itme is deleted.
I tried I to pass more variables in the checkKeycode function like checkKeycode(e, itemname, itemprice) for example, but its not working.
Thanks for help ...
So what I would like to do is:
Mouse goes over a link and then determines which key is pressed.
This seems to be ok with the following code:
function checkKeycode(e) {
document.onkeydown = checkKeycode
var keycode
if (window.event)
keycode = window.event.keyCode;
else if (e)
keycode = e.which;
switch (keycode) {
case 65:
alert("keycode: " + keycode);
break;
case 68:
alert("keycode: " + keycode);
break;
}
}
and this is one of the links:
<a href="link" onmouseout="document.onkeydown = null" onmouseover="checkKeycode()">text</a>
But now I want to be able to do some additional things according to which key is pressed.
For example somebody moves over the link and presses a and then an item is added to a shopping cart. Or he presses d and an itme is deleted.
I tried I to pass more variables in the checkKeycode function like checkKeycode(e, itemname, itemprice) for example, but its not working.
Thanks for help ...