# how can i write an custom Input Action in unreal c++

**URL:** <https://forums.unrealengine.com/t/how-can-i-write-an-custom-input-action-in-unreal-c/924839>\
**Category:** C++\
**Tags:** unreal-engine, CPP, question\
**Created:** [April 13, 2023, 5:36pm UTC](https://forums.unrealengine.com/t/how-can-i-write-an-custom-input-action-in-unreal-c/924839 "2023-04-13T17:36:08Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [April 13, 2023, 7:13pm UTC](https://forums.unrealengine.com/t/how-can-i-write-an-custom-input-action-in-unreal-c/924839/4 "2023-04-13T19:13:19Z")

</div>

```auto
FInputActionBinding CurBinding& = InputComponent->BindAction(TEXT("OpenMenu"), EInputEvent::IE_Released, this, &APlayerControllerGame::ActOnOpenMenu);
CurBinding.bConsumeInput = true;
CurBinding.bExecuteWhenPaused = true;

```

Where “this” in the example == APlayerController and the implemented method on it ActOnOpenMenu is marked UFUNCTION. Added example of how to set some parameters on the binding but they have defaults . PlayerControllers and Pawns are the common classes to use InputComponents on. If this would be implemented on a UserWidget, forget about InputComponents because they have their own input routing system:

> [Widget input: It SMELLS](https://forums.unrealengine.com/t/widget-input-it-smells/784112)

---

_[View the full topic](https://forums.unrealengine.com/t/how-can-i-write-an-custom-input-action-in-unreal-c/924839)._
