Install the Add-on Keymap Editor. It's in the official Kodi repository, so it's not hard to find. Using this Add-on, which will be installed under Programs, you can set any key on your remote control to control a certain function of your choosing in Kodi. Of course the key on the remote should give out a signal that is recognised by the box to do so.
I have already tried to use keymap editor but it does not work, the buttons assigns them but do not change their basic function, in fact, to remap some functions on the remote I've used this method, for example: play stop pause. I took from your example, the command file to go into my favorites that is not a function present in the standard linux commands and I think there are also codes to scan the library, but I can not find what they are.