@zmanz You are on the right track with all/retroarch.cfg. That's the starting place to look for keymaps for libretro emulators. In addition, you could look at configs that might also have key mapping in them according to the emulator. So, mame-libretro/retroarch.cfg would be next, assuming you placed roms in the corresponding folder. arcade/retroarch.cfg if you are using the arcade folder. You get the idea.
However, this brings up a less common issue when using a keyboard controller. . . mame2003 and possibly other lr emulators accept inputs via the "virtual" retropad controllers, but it ALSO SIMULTANEOUSLY accepts raw keyboard inputs. That's why you see both a key and a retropad referenced in the MAME GUI (in game menu brought up with <TAB>) when you are remapping in there. In other words, it's possible to have the retropad mapped in the retroarch.cfg file and have that be in direct conflict with the actual raw keypress that is setup inside MAME2003.
You could go into the MAME GUI and try to remap keys, but the layers of controls and remapping can get pretty confusing!
Here's a post from a while back where some of these details are described. It might be worth a read.