How to disable the "W" key using a bool?

First of all what I recommend for testing all of this is to use Print Strings so you can see exactly when it’s being called.
To disable a key there isn’t a node that literally “turns it off.” What you’re really doing is disabling the logic that runs behind that input. You could do this with branches, but if you want a cleaner and more scalable solution, the recommended way is to use Input Mapping Contexts (IMC) in Enhanced Input
( Documentation : Enhanced Input in Unreal Engine | Unreal Engine 5.6 Documentation | Epic Developer Community).

The cleanest and most scalable way to disable a specific key (like W for forward) is through IMCs. What you do is duplicate your default IMC (for example, IMC_Default - IMC_DisableKey) and in that copy remove the binding for the action you want to disable. In this case, that would be the forward movement action bound to W.
(IMC Without specific key )


(IMC Default with all keys )

In your PlayerController, create two events:

  • DisableKeys: removes the default IMC and adds your custom IMC without the W binding.
  • EnableKeys: does the opposite, removes your custom IMC and re-adds the default one.

From the Level Blueprint (or from your Bluepint ), you simply call DisableKey Event when the player enters a trigger and EnableKeyEvent when they leave, or at any other point where you want to toggle the behavior.
(Blueprint with a trigger)

Level Blueprint

The advantage of doing it this way is that your gameplay logic stays clean and separated from input logic. Instead of filling your Blueprints with branches and condition checks, you just switch contexts. This also lets you create different “control profiles” and scale the system easily without conflicts.

In case you want to disable it using a Branch, here’s a link where they talk about the topic, so you can better understand how it works:

And I’m also leaving it set up with an example of how it works. In my case I used Disable Input and Enable Input

And lastly, in case you want to know where the movement logic is and how to disable moving forward and backward, I’m leaving you an example with a Select and an Enable/Disable Forward/Backward . This disables the forward and backward movement logic whenever the player overlaps with the trigger, and re-enables it when exiting the trigger.

Hope it helps!

1 Like