| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Closed
Ok, this may seem a wierd question, because ive searched google for like a week to find an anwer.
I have 4 submit buttons in a form... each named "Submit" with the values "North", "South", "East", and "West". When a button is submitted it sends its value to a php script that determines which direction was clicked... this in turn moves a character around a map. Everything works flawlessly when a button is clicked..... However.... In the game clicking a direction gets repetative. I want to assign each button a key on the keyboard... so when that key is pressed it submits a value.... for example... "W" key is hit on the keyboard... the value "North" is submitted... or up/down/left/right.... say.. the "UP" key is hit, the value "North" is sent... My php code is pretty much irrelavent... but basically what im asking is, how to submit a specific button when a certain key is pressed.... is this even possible??? |
|
#2
|
|||
|
|||
|
all of that is probably easier to do in Flash if you can recreate your game in it.
either way, here it is Code:
<script language="JavaScript">
function arrowPress()
{
if (event.keyCode == 37)
{
alert("You pressed the left arrrow.");
return false;
}
else if (event.keyCode == 38)
{
alert("You pressed the up arrrow.");
return false;
}
else if (event.keyCode == 39)
{
alert("You pressed the right arrrow.");
return false;
}
else if (event.keyCode == 40)
{
alert("You pressed the down arrrow.");
return false;
}
else
{
alert("You pressed some other key.");
return false;
}
}
document.onkeydown = arrowPress;
</script>
it doesn't send any variables to php though. if you need any more help, or if i missed something, just post again |
|
#3
|
|||
|
|||
|
I already got the script i needed, thanks for the help tho.. and yes it would be easier in flash to do, but I hve other reasons for using php.
Thanks for the help anyways and ill close the topic.. forgot i had it up still. |
![]() |
| Viewing: Tutorialized Forums > Desktop Programming > Delphi > Closed |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|