- Home /
Keyboard and Controller Input Not Working in WebGL
Recently I made a game and put it on Game Jolt. I found that Game Jolt had an option for WebGL, so I took my game and built a version for WebGL as well. Afterwards, I quickly realized that my game was unplayable on WebGL because no keyboard or controller input was being registered by the game - only mouse clicks actually worked.
So I've been looking around for a while looking for an answer to this problem. I've seen several people complaining of the same problem but from different causes, many of which I didn't understand. I found some solutions that involved editing the index.html file of the WebGL build, but that didn't work for me either. I don't think this is caused by the game not being focused, and I don't have any text input fields that conflict with input that I would need to disable keyboard input for WebGL (which seemed to be the main issue for most other people with this problem).
I'm not super experienced with WebGL, so if this is just some rookie mistake or ignorance on my part I wouldn't be surprised. I apologize if this question has already been asked and solved before. Does anyone know why my keyboard and controller input stops working when using WebGL?
Answer by JstnMcBrd · May 03, 2019 at 05:28 AM
It only took another year for me to figure it out, but I eventually fixed the problem. It had nothing to do with WebGL or Unity itself. It was from lazy coding on my part.
I had a complex system that determined keyboard and controller input keys based off the operating platform, and that system failed to account for WebGL. Essentially, when in WebGL, the game stopped looking for any input because there wasn't a defined input system for that platform.
So pretty much, 100% my own fault and not an issue anyone else is likely to have. Just thought I'd mark the solution so others know that this isn't still a problem.