Published app wont accept keyboard input

My app has keyboard input which works fine when launched from the editor, and indeed when hosted elsewhere but not when published on playcanvas - wierd huh!

part 2 works fine - with first-person controller & physics

but part 1 does not - uses the hammer.min and camera scripts adapted from the standard ‘3d model viewer’ .

Update - I think it may be that I am setting global variables, need to try with an adapted version using only vars created inside playcanvas…

Try clicking with mouse first on screen of a game (iframe).
There is a “problem” where user is required to click by mouse onto iframe before it starts to accept keyboard input. This is general mechanics that browsers have. So if your game is in iframe - you need to ask players to click with mouse onto something first, this can be just a menu or something like so.

Please let me know if that resolves it.

Max, sorry for delay Ive only just seen this.

Problem is not resolved by clicking in window - Can you have a look?

remember its the version published on playcanvas which doesnt accept keyboard input. Mouse input, btw, is fine.

Yeah, I can confirm this, @max. Not sure what’s going on here. Can you take a quick look to see what’s the problem?

Just checked this link:
Keyboard and mouse seems to work, is the problem already resolved? And if so, what it was related to?

Hi Max, keyboard not working for me - running Chome 48.0.2564.82 m. Wasnt working for Will either.

Hey there - can you give me access to your project so I can debug some stuff? My username is “vaios”.

have done, cheers … the UI script is attached to the UI/HUD which is a child of the camera

It looks like this works if you click on the iFrame and then hit TAB. So it seems that something takes focus away from the iframe. How about doing this in the initialize method of a script:

setTimeout(function() {window.focus();})

I’m not sure if this will work like that but give it a go and if not I’m gonna fork your project and try some stuff out.

Note that this seems to be a problem in your project so some script is probably doing this. I can’t reproduce this in a new project.

OK great #. problem solved for now, - I am happy to ask users to hit tab to start.

for posterity heres more detail:

adding that window focus line:

setTimeout(function() {window.focus();})

Also solves the problem, but meanwhile it also disrupts the scaling of the model on screen, which is done in the camerascript, in turn relating to hammer.min.js

the scaling is controlled by these lines:

 if (meshInstances.length > 0) {
            var aabb = new pc.shape.Aabb();
            for (i = 0; i < meshInstances.length; i++) {

            var focus =;
            var halfHeight = aabb.halfExtents.y/2;  //**/2 to scale the model to fill screen**
            var halfDepth = aabb.halfExtents.z/2;   //**/2**
            var offset = 1.5 * halfHeight / Math.tan(0.5 * * Math.PI / 180.0);
            this.reset(focus, offset + halfDepth);
        } else {
            this.reset(pc.Vec3.ZERO, 3);