- Home /
WebGL Input - KeypadEnter registering as Return
Short version:
I'm making a game in WebGL and I need to be able to distinguish between KeypadEnter and Return (two very different keys on a keyboard).
However, in the browser build of my game, all KeypadEnter inputs somehow register as Return. That is, Input.GetKey(KeyCode.Return);
returns TRUE and Input.GetKey(KeyCode.KeypadEnter);
returns FALSE when the KeypadEnter key is being pressed.
Why does this happen?
(If you want to know exactly how I found the issue, keep reading.)
Long version: I made a test scene with a text object that prints out each key that is being pressed each frame.
void Update() { TextMesh text = GetComponent<TextMesh>(); text.text = ""; if (Input.anyKey) text.text += "anyKey\n"; for (int i = 0; i <= 509; i++) { if (Input.GetKey((KeyCode)i)) text.text += ((KeyCode)i).ToString() + "\n"; } }
When in the Unity Editor, when I press the Return key I see: and when I press the KeypadEnter key, I see: This is exactly what I want to see.
However, after I build the project to WebGL and upload it to Gamejolt, things stop working. I press the KeypadEnter key and I see: Same for when I press the Return key. Essentially, in a WebGL browser build, both Return and KeypadEnter register as Return. This doesn't make any sense to me. Anyone else have this issue or know how to fix it?
If you need more info from me to help answer my question, feel free to ask clarifying questions.
Your answer
Follow this Question
Related Questions
Shift gear from 2 sliders? 1 Answer
How to Use Key Combinations with the Control-Key? 2 Answers
Collision Not Working 1 Answer