- Home /
Keyboard unfocused in facebook canvas
Hi, I am having an issue in WebGL when running my game inside of the facebook canvas. I have an inputfield, and when I click on it and try to type something, it doesnt type anything but I do see the cursor inside of the inputfield. I have to click outside of the game, and then back in the game for it to work. In webplayer I dont have this problem, I think its because of the way webplayer and webgl are used inside of the facebook canvas. Anyone knows how to fix this issue? I tried adding tabindex=`1` inside of in the index.html but it didnt help.
Also, I did the exact same thing in a different project that was not in the facebook canvas, and this issue wasnt happening.
Answer by denisb · May 22, 2015 at 12:59 PM
So i've found a way to fix this. In the index.html file that get created when building for webgl, I added tabindex="1" in the , and also added focus(); in the first javascript call.
Answer by zzzzzz789 · Jul 15, 2015 at 11:57 PM
This should be fixed in 5.2 as the release notes on http://unity3d.com/unity/beta have: "WebGL: Fix iframe gaining focus when clicking on WebGL canvas"
To work around this for now, put this javascript in your index.html :
document.getElementById('canvas').addEventListener('click', function() {
document.getElementById('canvas').focus()
});