Issues with rebinding keys with Enhanced Inputs

Hey guys,

I’m having some trouble trying to rebind keys with the new Enhanced Inputs system. It just seams to be missing key settings. I’m trying to rebind a key to an action by using Unmap Key to remove the old mapping and then Map Key to map the new mapping to the action.

The problem I’m having is when using Map Key node its missing important key input settings, like the Is Player Mappable, Player Mappable Key Options, Triggers, Modifiers etc. The weird things is the Map Key node then returns a KeyMapping struct that contains all this info but its just blank. Which means I lose my Display Name for the input as well as modifiers for the new input.

I’ve also tried the Add Player Mapped Key node which does work better as it allows you to replace a key input instead of having to remove one and adding a new one. But it doesn’t save to the context, so as soon as you restart the game the controls will revert back to their previous settings. Is there a way to save these new mapped key inputs?

EDIT: So I’ve found that even when using the Map Key node with the Mapping Context object after restarting the engine the Mapping Context blueprint will revert to the previous key input mappings. So I have no idea how your meant to implement a rebind key system that saves the new key inputs.

Any suggestions would be amazing, thanks guys :slight_smile:

Hi!

I encountered the same problem. Doing it the following way edits the mapped key & keeps all the other map settings.


Be sure to get the mappings array element as a reference (not a copy) otherwise it won’t update the mapping.

The KeyMapping variable is a reference to the mapping we’re trying to change & the MappingContext variable is a reference to the input context that contains the KeyMapping.

Hope this helps!

Hey, yeah I came up with something similar but still had the issue of the keys reverting after reopening the project, I reported this to Epic and they’ve added the bug to the unreal bug tracker.

Thank you so much for this!

I see that it was flagged “by design” did you by any chance learn how to fix it?

I ended up creating a save system using the unreal engine save system that stores the name and key of each binding that gets rebound by the player, then on begin play of the game instance I load that save file and reapply the key binds and this seams to work fine. Not sure if this is the correct way to do this but it does work.

Highly recommended for anyone building an Unreal Engine game with Enhanced Input and customizable key bindings. Solid work.
https://www.fab.com/listings/e8a77976-b4d4-4e8f-a4b4-c6a71a98554d

yea the Map Key node creates a bare mapping without the PlayerMappableOptions — thats why IsPlayerMappable / DisplayName disappears after rebind. you need to read the original FEnhancedActionKeyMapping first and pass its PlayerMappableOptions into the new mapping, or use Map Player Key / Add Player Mapped Key In Slot from UEnhancedInputUserSettings which preserves it. also call UpdateControlMappings after.

if you want it without wrestling the struct, advanced enhanced input key remapping on fab Advanced Enhanced Input Key Remapping / Binding / Profiles / Local & Cloud Save. | Fab handles that for you — it copies the options, does conflict detection (swap/replace/cancel prompt) and keeps reserved keys. saves a lot of boilerplate around that Map Key gotcha.