- Home /
C# String Array Has Missing or Incorrect Keycode Strings
I have a string array that either has missing keycode strings or has the incorrect syntax of those keycode strings. I've followed the guidelines for keys down below and they should be correct. But when I run the script it can't find the keycode strings. Is there any place I could look to double check my syntax outside of the Unity Manual?
http://docs.unity3d.com/Manual/ConventionalGameInput.html
private string[] keys = new string[]{
"[return]",
"[equals]",
"left command",
"left apple",
"left windows",
"right command",
"right apple",
"right windows"
"print",
"sysreq",
}
void Update (){
for (int i = 0; i < keys.Length; i++)
if (Input.GetKeyDown(keys[i])) {
Debug.Log(keys[i]);
}
}
Answer by Eric5h5 · Nov 06, 2015 at 05:23 AM
Most of those keys don't exist and/or are not correct; take another look at the docs you linked to for what's actually used. e.g., there is no "left command" or "left apple", instead it's "left cmd". The list of special keys is complete; if it's not on that list, you can't use it; e.g. no "print" or "sysreq". The only error in the docs I can see is that "[equals]" doesn't work, instead it's "equals" for some reason. (You'd use "=" for the regular, non-numeric-keypad key.) The keypad enter key is "enter", and the regular return key is "return".
Note that you'd be better off using $$anonymous$$eyCode anyway, rather than strings. $$anonymous$$eyCode is an enum so any errors are caught at compile time rather than runtime.
Answer by SeasiaInfotechind · Nov 06, 2015 at 04:46 AM
Hii, I hope below mentioned link will solve your problem http://forum.unity3d.com/threads/input-not-found.81798/
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Most efficient way to convert string[] to int [] in C#? 2 Answers
if a string has certain letter(s) or number(s) 2 Answers
bool[string] = true; array possible? 2 Answers
Distribute terrain in zones 3 Answers