WebGL - Module.doNotCaptureKeyboard: true or Module.keyboardListeningElement: ... NOT WORKING ANYMORE

Since the Update to the latest Unity 5 Editor version these two options do not work anymore (Module.keyboardListeningElement, Module.doNotCaptureKeyboard) .

The WebGL Canvas is always eating all the keyboard input, no matter if these options are set or not.

Built with Unity 5.0.1 before and those options worked and I was able to use Input fields, etc. in the DOM.

Built with Unity 5.1.1 now and this option isnt working anymore.

Is there any change I have missed?

Thanks for the help.

I have created a workaround. Still waiting for “the right way” answer though.

  1. Add html input field to your page (or use the one which worked for you with Unity 5.0.1), e.g.:

  2. Add following javascript function to your page

    hackWebGLKeyboard: function ()
    {
    var webGLInput = document.getElementById(‘WebGLKeyboardInput’);
    for (var i in JSEvents.eventHandlers)
    {
    var event = JSEvents.eventHandlers*;*
    if (event.eventTypeString == ‘keydown’ || event.eventTypeString == ‘keypress’ || event.eventTypeString == ‘keyup’)
    {
    webGLInput.addEventListener(event.eventTypeString, event.eventListenerFunc, event.useCapture);
    window.removeEventListener(event.eventTypeString, event.eventListenerFunc, event.useCapture);
    }
    }
    }
    3) Call the hackWebGLKeyboard() function after WebGL has been initialized (I’m calling it from Start method on MonoBehaviour in scene)
    4) Any time you need to switch input to your game, call following javascript as before
    document.getElementByID(‘WebGLKeyboardInput’).focus()