- Home /
Input Key named: LeftAlt is unknown
I got this from
if (!readyState && GUI.Button(Rect(mx,my+(mbh+5)*it,mbw,mbh), ch.heroList[i].name)){
var switchSide: boolean;
>>> if (Input.GetKey("LeftAlt")) switchSide = true; else switchSide = false;
//if (Event.current.alt) switchSide = true; else switchSide = false;
nv.CLIENT_setchar(ch.heroList[i].id.ToString(), switchSide);
}
From unity script reference Input.GetKey I quote: "For the list of key identifiers see Input Manager." But there is no key identifiers list to be found there.
Finally I manage to find the KeyCode page. And there I see LeftAlt.
what gives?
edit: so basically its Input.GetKey(KeyCode.LeftAlt) (or Input.GetKey("left alt") defined in program options) and not Input.GetKey("LeftAlt")
thanks to NoTakeful and shadows_s for pointing it out
Answer by shadows_s · Jun 26, 2014 at 11:12 AM
There are two overloaded methods Input.GetKey(KeyCode) and Input.GetKey(string)
For Input.GetKey(KeyCode)
Edit -> Project Setings -> Input add your key "LeftAlt" there
For Input.GetKey(string)
Input.GetKey(KeyCode.LeftAlt);
Answer by NoTakeful · Jun 26, 2014 at 11:08 AM
The actual name of the input that correlates with the key must be put in there, not the name of the button on the keyboard if that is the issue. For example, Spacebar is the "Jump" key. So you can add a named key that has the alt button as the key in the
Edit > project settings > input > axes >
then change it to one higher on the "Size" to add another axes and whatever you name the axes you have to put as the key string.
yes what confused me was that (Input.Get$$anonymous$$ey ("space") worked..
Your answer
Follow this Question
Related Questions
Noob - Use the ESC, Shift and Command Key?? 1 Answer
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
How to get the key from the button name 1 Answer
Key remapping inGame 0 Answers
Controller menu keylist 1 Answer