Is there a way to get what key that is currently gets pressed down?
I tried with Input.inputString
but it just returns an empty string.
void Update () {
if (change && Input.anyKeyDown) {
Debug.Log(Input.inputString);
}
}
Is there a way to get what key that is currently gets pressed down?
I tried with Input.inputString
but it just returns an empty string.
void Update () {
if (change && Input.anyKeyDown) {
Debug.Log(Input.inputString);
}
}
Hello, i have managed to do what do you want with an one different thing, it is not an anykeydown, it is anykey. If i use anykey it works but if i use anykeydown it doesn’t work, i have no idea about this, maybe you can figure it out. Here it is;
#pragma strict
function Update ()
{
if(Input.anyKey == true)
{
for(var i : char in Input.inputString)
{
print(i);
}
}
}
Try:
if (Input.GetKeyDown) {
Debug.Log (KeyCode);
}
or:
if (Input.GetKeyDown (KeyCode.something)) {
//do whatever
}
The example is in the docs.
//Detects keys pressed and prints their keycode
function OnGUI() {
var e : Event = Event.current;
if (e.isKey) {
Debug.Log("Detected key code: " + e.keyCode);
}
}