What would be the best way to remap input for both keyboards and controllers as the game is running?

For example, is it possible to detect exactly what input action the user has taken when asked to “Press new key to mappped to control”?

There are methods to find out certain things: Input.InputText, Input.GetKey, Input.GetAction.

There are also methods to update action settings
eg: SetActionConfigByName(…)

Those seem to work … but what about the following:

  • various keyboard layouts: QWRTY, AZERTY, etc
  • international keyboards: European languages with accented characters, Asian languages, etc
  • the same letters might be mapped to different keys for some languages
  • Keyboard layouts can be remapped at the operating system level

Would the Input methods mentioned above be able to handle those scenarios?

For now, a few possible solutions came to mind.
Input.InputText can detect keyboard key press (or rather letter representation). That value could be stored and then compared to.
However, to use Virtual Input, the Keyboard.[key name] value would is needed for Input.SetActionConfigByName(…). Perhaps, shoring string values of letters and Keyboard.[key letter] value pairs in a dictionary/look up table and looking up corresponding value could work?

Or perhaps there is something that we haven’t come across yet that would be a better option?

1 Like