How to define Kodi keynames toward CEC codes

This quote is from a thread where the addition of a custom action to a keypress on a HDMI CEC remote is discussed:

Just curious
Is there any way in a keymap file to define the key codes for kodi button names like play, pause, rewind etc?
Then the actual settings for the actions could use these Kodi names rather than the key id in the remainder of the keymap files.
I have seen that the kemap xml files are read in alphabetical order so if a “master” file is named such that it always is the first then all other files need not bother with the actual codes sent by certain files…

The reason I ask is that I have multiple OSMC devices which move between installations with different TV brands. I would like to customize some key actions and when switching between systems it would be useful to only have to change one file where the actual CEC codes are connected to Kodi names and in the actual keymap file where the custom actions are defined I could then use the same settings across devices.
But I have not found if this is possible or not.

This would be a question for the Kodi devs and not OSMC. I would assume that if you asked the answer would either be a simple “no” or else something to the effect of “we would consider a pull request”. The CEC actions are not default mapped with external master keymap files like all other remotes are and I suspect their is probably a legitimate reason why. Given that CEC input does not put correct entries on debug logs I suspect it takes a different processing path and as such dropping in some names wouldn’t be trivial.

The key names wouldn’t actually provide any extra function for your situation though as they just provide a more user friendly way to manually make/edit keymaps. For what you want you just put in duplicate entries mapped to all the buttons for the different Kodi boxes such as…

<keymap>
  <Home>
    <keyboard>
      <key id="230">System.Exec(/home/osmc/bin/getstreamlist)</key> <!-- comment to note play on TV 1 -->
      <key id="234">System.Exec(/home/osmc/bin/getstreamlist)</key> <!-- comment to note play on TV 2 -->
      <play_pause>System.Exec(/home/osmc/bin/getstreamlist)</play_pause>
      <p>System.Exec(/home/osmc/bin/getstreamlist)</p>
    </keyboard>
  </Home>
</keymap>