- Home /
What is up arrow/key/button, whatever, called in javascript?
i am wanna program the PlatformerController script from the 2d turorial to jump with the "up key", but when i try up arrow or up key or up button none seem to work! please help! ALL help is GREATLY appreciated! Thanks!
Answer by Mike 3 · Aug 25, 2010 at 01:16 PM
If you're using GetKey[Up/Down], you can just use GetKey(KeyCode.UpArrow)
If you want to use the string version (honestly I wouldn't though), you just use "up"
Here's the list of keycodes in case you need them:
http://unity3d.com/support/documentation/ScriptReference/KeyCode.html
@mike Why you wouldn't use the string version ? I use it quite a lot but I also use a custom made let's say joystick and grouping the controls under strings it is quite handy, apart from that it could be configured easily by the end user.(not for my case). I work these days on it and if you found problems I would be really happy to hear ....
for GetButton you'd use the string version (there isn't any way around that) - for Get$$anonymous$$ey, you're only working on predefined keycodes anyway, so it's just taking the string version and working out which keycode it is behind the scenes. Since it's pretty much the same, I'd just go with keycodes as they're checked at compile time, and you can't accidentally make a typo without noticing it
Your answer

Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Setting Scroll View Width GUILayout 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Javascript in Unity, Including iPhone API's (Objective C?) 2 Answers
How to toggle a key for a car to go forward or backward? 1 Answer