Page 1 of 1

Disable Specific Keys

PostPosted: Wed Mar 09, 2011 9:15 pm
by phyzix5761
Is there a way to disable a specific key when an event takes place? For example, disabling left arrow when player presses right arrow.

Thank you!

Re: Disable Specific Keys

PostPosted: Wed Mar 09, 2011 9:32 pm
by Hblade
Yes, there is a way. If your using the KeyDown event, just use a variable :) Click variables, add, and make a variable called Keys. Click Array, click yes. Now however many keys you are using for the controls, put that number in the box + 1, so say your using like, 5 keys. you'd put 6 in the box. Now click okay, open up Notepad and write this down
Keys[0] = L (Or what ever key your using)
Keys[1] = A
Keys[2] = Etc...



Now, your almost done! :) before the code for your keydown event, make an if statement.
Code: Select all
If (Keys[0]==0) { //Your key was L in this case, as seen above
YOUR_CODE_HERE
}


Put the } at the very bottom of all of the code.





Now to disable and re-enabel that key, all you gotta do is call the variable. Example:
Code: Select all
//disable the key
Keys[0]=1;

//Enable the key
Keys[0]=0;


hope this helped :D

Re: Disable Specific Keys

PostPosted: Wed Mar 09, 2011 9:37 pm
by Hblade
If your trying to fix the moonwalk bug, there are many ways :) however I dont have any links at the time xD

Re: Disable Specific Keys

PostPosted: Wed Mar 09, 2011 10:45 pm
by phyzix5761
Thanks for your response. I will test it later.

I fixed the moonwalk bug. This is for another bug. I want to allow the player to only walk in one direction at a time while still being able to use abilities/weapons.

Re: Disable Specific Keys

PostPosted: Wed Mar 09, 2011 10:46 pm
by schnellboot
why do you have to disable some keys then?