# How to create and rebind Action and Axis Mappings at runtime?

**URL:** <https://forums.unrealengine.com/t/how-to-create-and-rebind-action-and-axis-mappings-at-runtime/584483>\
**Category:** C++\
**Tags:** unreal-engine, UE5-0, question, CPP\
**Created:** [June 18, 2022, 2:39am UTC](https://forums.unrealengine.com/t/how-to-create-and-rebind-action-and-axis-mappings-at-runtime/584483 "2022-06-18T02:39:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zos](https://forums.unrealengine.com/u/zos)\
**Post date:** [June 18, 2022, 2:39am UTC](https://forums.unrealengine.com/t/how-to-create-and-rebind-action-and-axis-mappings-at-runtime/584483/1 "2022-06-18T02:39:05Z")

</div>

You can create new global Action and Axis Mappings in the Input section of the Project Settings. These are saved in the .ini files in the Config directory.

However, is it possible to create a new Action or Axis Mapping with C++ during play?

Is it possible to rebind an Action or Axis Mapping with C++ during play? (like to an additional key, or to change the key)

How do the Key Bindings options menu in unreal games work? Which API do they use?

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [June 18, 2022, 8:27am UTC](https://forums.unrealengine.com/t/how-to-create-and-rebind-action-and-axis-mappings-at-runtime/584483/2 "2022-06-18T08:27:28Z")

</div>

> is it possible to create a new Action or Axis Mapping with C++ during play

Not sure about this one; I once tried creating a brand new binding at runtime, but I couldn’t find a way to properly call `SetupPlayerInputComponent()` after that, so it didn’t work.

> Is it possible to rebind an Action or Axis Mapping with C++ during play?

This is of course possible, but with a few issues I’ve come across.

```auto
UInputSettings* MyInputSettings = UInputSettings::GetInputSettings();
FInputActionKeyMapping MyActionMapping;

FInputChord NewKey; // this value can be retrieved from key selector widget
NewKey.Key = EKeys::TheKeyYouNeed;

MyActionMapping.ActionName = FName("YourActionName");
MyActionMapping.Key = NewKey;

MyInputSettings->AddActionMapping(MyActionMapping);
MyInputSettings->SaveConfig();

```

To see what keys are already set:

```auto
TArray<FInputActionKeyMapping> OutMappings;
MyInputSettings->GetActionMappingByName(ActionNamePrimary, OutMappings);

```

It’s pretty much the same with axis, just change Action by Axis in all instances, and maybe you’ll need to set `MyAxisMapping.Scale` to for some bindings.

Now the main issues I mentioned:

1. You can’t _change_ the existing bindings, you can add new ones and remove old ones. This means that you first have to get the existing binding key, save it to a variable, add a new key, then remove the old one. If you first remove the old one and then add the new one, the input may become disabled until you restart the game and `SetupPlayerInputComponent()` is run again. I couldn’t see the pattern, it would happen randomly.
2. If you add multiple keys to the same action (like you want to have a primary and a secondary key), they will be sorted in some way. No matter what I did, I couldn’t do so that the first binding would always be [0], and the second [1]; they would change places and be inconsistent. So I finally went with separate action names for primary and secondary.

---

<div class="post-metadata">

**Author:** ![zos](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zos](https://forums.unrealengine.com/u/zos)\
**Post date:** [June 18, 2022, 8:22pm UTC](https://forums.unrealengine.com/t/how-to-create-and-rebind-action-and-axis-mappings-at-runtime/584483/3 "2022-06-18T20:22:06Z")

</div>

Thanks. By during play I meant kind of at runtime but not actually between BeginPlay and EndPlay.

Your code was helpful. The relevant classes are `UInputSettings`, which is the global and connected to the .ini, and `UPlayerInput` which is part of the `APlayerController`. It looks like `UPlayerInput` is setup on GameMode/GameSession `RestartPlayer` and `ClientRestartPlayer` in multiplayer.

Also see `void APlayerController::InitInputSystem()` and `APawn::PawnClientRestart()`

---

<div class="post-metadata">

**Author:** ![ShadowBr0kerz](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shadowbr0kerz/32/1201558_2.png) [@ShadowBr0kerz](https://forums.unrealengine.com/u/ShadowBr0kerz)\
**Post date:** [September 5, 2026, 8:47am UTC](https://forums.unrealengine.com/t/how-to-create-and-rebind-action-and-axis-mappings-at-runtime/584483/4 "2026-09-05T08:47:41Z")

</div>

in 5.x that Project Settings Action/Axis array is deprecated — for runtime rebinding use `UEnhancedInputUserSettings`. register your IMCs via `RegisterSettings` on BeginPlay, then per rebind `Unmap Player Key` / `Map Player Key` + `Save Settings`. to add a key rather than replace, use `Map Player Key` without unmapping first; to add a whole action at runtime, add an IMC with `EnhancedInputLocalPlayerSubsystem -> AddMappingContext`.

if you want profiles + conflict checks + local/cloud save on top, advanced enhanced input key remapping [Advanced Enhanced Input Key Remapping / Binding / Profiles / Local & Cloud Save. | Fab](https://www.fab.com/listings/e8a77976-b4d4-4e8f-a4b4-c6a71a98554d) wraps that — runtime Apply without restart and keeps PlayerMappableOptions intact.
