When running a Unity project as a WebGL app is there way to catch the site's input events (e.g. keypress) once the application is running?
Currently once the Unity app launches it eats keyboard events so that I can't type in to my text boxes on the page. The best workaround I could come up with is to use jQuery to directly read the keypress
event:
$('#input_message').keypress(function(evt){
event.preventDefault();
var code = evt.keyCode || evt.which;
var key=String.fromCharCode(code);
$('#input_message').val($('#input_message').val() + key);
});
};
This works for my immediate needs but I'm hoping there is a cleaner way through the Unity API.
Versions
- Chrome v43
- Unity 5.1.1f1
This question has no solution, so if someone comes up here, there is a short path:
This was taken from here.
The property you are looking for is WebGLInput.captureAllKeyboardInput.