An update - just for interest
I have two buttons programmed on the remote - Option (used for invoking the context menu) and the channel up/down button (for audio delay). LibreElec/Kodi is running on a Dell Optiplex i5 and its generally (ie when we don't get a power cut) left running and it goes to sleep when the TV is turned off.
My wife uses the remote and I use a mini keyboard.
If we switch back to TV before turning the TV off then on waking up Kodi by pressing a key (other than Esc) on the mini keyboard the programmed buttons on the remote work. However, if the TV is switched off whilst still showing Kodi then on waking up the programmed buttons have lost their programming and the option button shows the TV options menu. Flipping from Kodi to TV and back restores the programming.