- Home /
KeyCode and ? (question mark keyboard)
In reference to the unity documentation: http://unity3d.com/support/documentation/ScriptReference/KeyCode.html
If I understand this right, I should be able to use KeyCode.Question similarly to the code they show on the Input.GetKeyDown doc page.
This is what my code looks like
void Update()
{
if (Input.GetKeyDown(KeyCode.Question))
print("Question key was pressed");
else if (Input.anyKeyDown)
Debug.Log("Keyboard Down Key is '" + Input.inputString + "'");
}
But the output is always the anyKeyDown output, showing whatever key I pressed, like this:
Keyboard Down Key is ''
Keyboard Down Key is '?'
Keyboard Down Key is 'a'
Keyboard Down Key is 's'
Keyboard Down Key is 'd'
Keyboard Down Key is '?'
Any ideas?
Answer by DaveA · Jul 08, 2011 at 02:28 PM
You're using print and Debug.Log. Try using Debug.Log for both. Do you need the else? because I've occasionally seen (what must be a Unity bug) where logic like this, esp Input, can cause oddness.
Also the keyboard handling has many bugs, see this: http://answers.unity3d.com/questions/57147/mac-keys-not-showing-up-or-very-strangely.html
Print 'should' work in the Update function (but I always use Log as well). I cannot imagine that this would be caused by the else either, if it were then there are dozens and dozens of scripts of $$anonymous$$e that would fail. Do you have/remember any examples of this 'oddness'?
Your answer
Follow this Question
Related Questions
Key not recognized 2 Answers
Shift + KeyCode.Equals works in Unity Editor but not on WebGL build 0 Answers
Turn Currently Held Button To A KeyCode(C#) 1 Answer
Text Prompt Problem 1 Answer
Mac OS Russian Keyboard - Input problem 0 Answers