I’m making a typing speed test game in WebGL for a research project that can:
- Record the exact keys pressed and when (e.g. Shift + d instead of just D). This means Input.inputString is unhelpful.
- Record when the keys are released.
I have read here that Event.Current in OnGUI() has poor performance, so I have implemented their suggestion of Input.GetKeyDown and a Foreach loop in Update(), following all of their steps.
This is working great in the Editor (both 1 and 2 work), but when I do a development / normal build as WebGL, nothing seems to happen when I press the keys. When I Debug.Log in OnKeyDown(), I can’t find the log in the javascript console.
Could anyone comment on whether the linked answer above should work in WebGL? I haven’t used the interface stuff before.
It seems the original answerer has been inactive since 2018, so I would appreciate any suggestions on how to fulfil my 2 goals in WebGL. Especially ones that are relatively quick to implement as I’m on a time crunch.