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

**URL:** <https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160>\
**Category:** Questions\
**Created:** [November 22, 2019, 6:59pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160 "2019-11-22T18:59:32Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![i73](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/i73/32/3167_2.png) [@i73](https://forum.babylonjs.com/u/i73)\
**Post date:** [November 22, 2019, 6:59pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/1 "2019-11-22T18:59:32Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/a/a26b241c8cea7011548b7039e3c0eb48626e1bb2.png)  
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](https://doc.babylonjs.com/how_to/customizing_camera_inputs)]([http://inputs](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?

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gijs/32/44_2.png) [@Gijs](https://forum.babylonjs.com/u/Gijs)\
**Post date:** [November 22, 2019, 8:17pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/2 "2019-11-22T20:17:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![i73](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/i73/32/3167_2.png) [@i73](https://forum.babylonjs.com/u/i73)\
**Post date:** [November 22, 2019, 8:23pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/3 "2019-11-22T20:23:56Z")

</div>

> [@Gijs](#):
>
> 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?

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/4/4ab251a92b6fc07957524bda8d8b5e28e026bf31.png)

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gijs/32/44_2.png) [@Gijs](https://forum.babylonjs.com/u/Gijs)\
**Post date:** [November 22, 2019, 8:37pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/4 "2019-11-22T20:37:20Z")

</div>

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

> <https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/Inputs/freeCameraKeyboardMoveInput.ts#L107>

---

<div class="post-metadata">

**Author:** ![i73](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/i73/32/3167_2.png) [@i73](https://forum.babylonjs.com/u/i73)\
**Post date:** [November 22, 2019, 8:47pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/5 "2019-11-22T20:47:23Z")

</div>

I did pass a null element as well, I’m still receiving inputs when I do ☹  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/4/45891f93905be9d2a8850e9577bce23095f38c4f.png)

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gijs/32/44_2.png) [@Gijs](https://forum.babylonjs.com/u/Gijs)\
**Post date:** [November 22, 2019, 8:52pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/6 "2019-11-22T20:52:05Z")

</div>

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

[https://playground.babylonjs.com/#5D84W2](https://playground.babylonjs.com/#5D84W2)

---

<div class="post-metadata">

**Author:** ![i73](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/i73/32/3167_2.png) [@i73](https://forum.babylonjs.com/u/i73)\
**Post date:** [November 22, 2019, 8:56pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/7 "2019-11-22T20:56:44Z")

</div>

> [@Gijs](#):
>
> That’s odd, on the playground it works fine:

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](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/0/0b6693fe9fc6bf0928b181396d8bee3c9d992cab.png)

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/3/32554df1577d819d4e4dc93dc41408c07a999cd3.png)

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gijs/32/44_2.png) [@Gijs](https://forum.babylonjs.com/u/Gijs)\
**Post date:** [November 22, 2019, 9:01pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/8 "2019-11-22T21:01:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![i73](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/i73/32/3167_2.png) [@i73](https://forum.babylonjs.com/u/i73)\
**Post date:** [November 22, 2019, 9:12pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/9 "2019-11-22T21:12:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gijs/32/44_2.png) [@Gijs](https://forum.babylonjs.com/u/Gijs)\
**Post date:** [November 22, 2019, 9:17pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/10 "2019-11-22T21:17:38Z")

</div>

> [@i73](#):
>
> Do you mean it doesn’t capture keyevents? Because the free cam default doesn’t move the camera position.

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?

---

<div class="post-metadata">

**Author:** ![i73](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/i73/32/3167_2.png) [@i73](https://forum.babylonjs.com/u/i73)\
**Post date:** [November 22, 2019, 9:35pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/11 "2019-11-22T21:35:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gijs/32/44_2.png) [@Gijs](https://forum.babylonjs.com/u/Gijs)\
**Post date:** [November 22, 2019, 10:04pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/12 "2019-11-22T22:04:11Z")

</div>

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

> <https://github.com/BabylonJS/UnityExporter/blob/59f751da37f532fec7e20db97561d3c217f18268/Manager/src/babylon-manager.ts>

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

> <https://github.com/BabylonJS/UnityExporter/blob/59f751da37f532fec7e20db97561d3c217f18268/Manager/src/babylon-manager.ts#L1674>

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

---

<div class="post-metadata">

**Author:** ![i73](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/i73/32/3167_2.png) [@i73](https://forum.babylonjs.com/u/i73)\
**Post date:** [November 22, 2019, 11:07pm UTC](https://forum.babylonjs.com/t/freecamerainputsmanager-contains-a-addkeyboard-but-no-removekeyboard/7160/13 "2019-11-22T23:07:02Z")

</div>

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!
