Are you using RetroPie 4?
It looks like you have updated some keys for the keyboard in your /all/retroarch.cfg file.
The defaults should be:
http://pastebin.com/raw/WrvnD9Gh
You can copy that to your file to test.
But it may well be the controller file that is having issues, can you post that on pastebin?
It should be in /opt/retropie/configs/all/retroarch-joypads/
This will also help:
https://retropie.org.uk/forum/topic/3/read-this-first