Is it even possible to dynamically add composite keybind with the new Input System?

Everywhere I look, it's like Unity's new input system forces you to preemptively define if a binding is going to have 1, 2, or 3 bindings (x mod + 1 binding).


Well... what if I want the dynamically enter them at runtime like so?


Here I'm looking for the player to set their preferred keybind and in this case there's two. One composite and one single bind. How can I accomplish this where I don't have to preemptively define a binding type?

Can be done but requires a little bit of custom scripting.

  • Copy over TwoModifiersComposite (or ThreeModifiersComplete depending on the max num of modifiers one wants).
  • Modify it to allow modifiers to not be bound and then simply be considered always on.
  • Register it under the same name (will simply replace the built-in definition).
  • Use RebindingOperation.OnPotentialMatch. If it's a modifier key press, save it and kick it out of the candidates. If it's something else, accept the match.
  • From RebindingOperation.OnApplyBinding, check which of the saved modifiers are still pressed and then initialize the part bindings of the composite appropriately.

You'd still have to anticipate the need but otherwise, it'd be fairly straightforward.

Ah, regarding the title, yes, you can also dynamically insert and remove bindings, including composite bindings. But the approach above would probably be more robust and easier to do.

Thanks for the suggestions! I was fighting so much against Unity’s new input system I decided to trial Rewired and it was much easier to work with and managed to get what I needed out of the box without too much hassle. I feel like Unity made a mistake with the input system have to predefine bindings instead of just listening and then evaluating the outcome…

Appreciate you stopping by and offering help!