Move UniversalCamera without a KeyCode

Hey there. I am using a UniversalCamera for some game. In combination with keysUp, keysLeft, … I attached KeyCodes to the UniversalCamera so it will move on keydown, which is working perfectly fine.

Now, let’s say I have some function that should trigger keysLeft, like myCamera.moveLeft(). I couldn’t find anything like it in the docs, is there actually something like this?

Here is a playground having a UniversalCamera where you could move with “W, A, S, D”.

So, if I understand you correctly, you want to trigger the forward move without a keydown action. Move the camera forward not based on browser events.

This is not an “official” solution, as we don’t recommend using private members, but adding and removing from the keyboard input’s _keys array will get you when you want to go:

FreeCamera_MouseWheel | Babylon.js Playground (

Otherwise, you can look into the free camera keyboard input and replicate the code responsible for movement. You can also implement your own input system that will support that.

1 Like

Thanks a lot! Ya I already thought of implementing that on my own, just thought there would be another solution I was missing. But ya the private member would be my way to go actually. I am also no big fan of using private members, but this is a little better as I reuse the existing code from the UniversalCamera directly.