Click to See Complete Forum and Search --> : Need SERIOUS help with key binding/mapping


Trigunflame
04-07-2003, 08:19 AM
Im working on a php rpg with some others, but I want to be able to use the arrow keys to navigate the character using the up arrow/down arrow/left arrow/right arrow, and you move your character through links


var left="<? echo $url.$west;?>";
var up="<? echo $url.$north;?>";
var right="<? echo $url.$east;?>";
var down="<? echo $url.$south;?>";


can ANYONE give me a example for doing this, all i want is when you press the up down left or right it, produces the same result as if you pressed a link. to move left or right etc..

gil davis
04-07-2003, 09:16 AM
To get access to keypresses, you have to assign an event handler to the document or window for the keydown event.if (document.layers) document.captureEvents(Event.KEYDOWN);
document.onkeydown = myKeyDn;
function myKeyDn(e) {
if (window.event)
alert(event.keyCode);
else
{alert(e.which + "\n" + e.modifiers);}
return false;
}The codes are: left = 37;
up = 38;
right = 39;
down = 40; Netscape does not give you a universal event like IE does. NS 4 gives a code of 0 for the arrow keys (real useful).