To change keyboard layout please try that: From Main menu got to Retropie and then select Raspi-Config.
This will open the configuration tool. Move down to and select Internationalisation Options:
On the next screen, choose 'Change Keyboard Options':
Unless you have one of the keyboards in the list shown on the next screen, choose one of the Generic keyboards:
On the next page you will be presented with the language choices for the current keyboard. If the language is not the one you have, choose 'Other':
Then choose the country of origin of the keyboard:
Followed by the keyboard layout:
Then the key to be used as the AltGr key (used by some keyboards to enter alternative characters. At this stage it is best to choose the default for the keyboard layout:
#
And unless you need a compose key, set 'no Compose key':
And finally you should choose NOT to terminate the X server (GUI) if you press Control-Alt-Backspace, as it's annoying to accidentally close the GUI when you are in the middle of using it!
You will be returned to the main configuration menu. Use the right cursor key to select Finish, and press return to go back to the terminal window.