`FreeCameraInputsManager` contains a addKeyboard() but no removeKeyboard()?

The InputsManager (or the free cam inputs manager) contains an add addKeyboard()


what I would like to do is remove the keyboard input during GUI display (pause menu) but after reading the docs for the inputs: [Customize Camera Inputs - Babylon.js Documentation](http://inputs docs) and reading the source (inputs interface) there doesn’t seem to be a enum or array of inputs I can figure out to give me access to the cameras input controls to toggle them on and off, can someone help me with code please or an easy function?

You can do
camera.inputs.attached['keyboard'].detachControl();

I was trying to use that earlier but detached control takes in a nullable element, don’t I pass it the keyboard element?

My bad, you can pass null to make it work. The element is the canvas, but FreeCameraKeyboardMoveInput doesn’t use it:

I did pass a null element as well, I’m still receiving inputs when I do :frowning:
image

That’s odd, on the playground it works fine:

https://playground.babylonjs.com/#5D84W2

1 Like

Do you mean it doesn’t capture keyevents? Because the free cam default doesn’t move the camera position.

Am I missing something? After logging out the inputs after the detachedcontrol on the playground
the keyboard still seems to be “attached”

image

Yes, the keyboard (actually the input manager for the keyboard) is still attached to the camera, but it isn’t listening for keyboard events on the canvas anymore

1 Like

Hmmm, well it doesn’t work for me in my case, it’s still accepting inputs. Is there any way to debug where the inputs are coming from? Because I have a suspicion it’s not on the camera.

I didn’t see this line the first time… in the playground you cannot move the camera with the arrow keys when the control is detached, otherwise you can. The problem in your project is that the camera can still be affected with the keyboard, right?

1 Like

Okay so I understand what my confusion with the freecam was in the playground it uses the arrow keys and not WASD so you’re correct, it does disable input as intended (I just thought WASD was default).

In my build (unity toolkit) when calling detachControl() it still accepts movement with the WASD keys and arrow keys.

So I’ll need to figure out where these controls are coming from or possibly there’s another input class?

I’m kind of thinking I’m just going to hack the character speed to zero, unless you can suggest a better way?

1 Like

I don’t know how the toolkit works, but what you’ll need seems to be in here:

More specifically, this may be function that causes the inputs:

There is also an option to disable user input, but I haven’t seen anything for the keyboard specifically.

In any case, pinging the author, the legend, @MackeyK24

1 Like

Unfortunatly the Scene manager class is different and I’ve read the entire one I have and there’s disable user inputs, and that’s all.

I’m just going to hack it with camera.speed = 0 when I need to stop player movement. Seems like the fastest way, spent way too long on this.

Thanks for all your help Gijs!

1 Like