there are different options to do this but if you're looking for something similar to what can be done in the arpeggiator (keep a key pressed on boot to configure midi channel and hold a 'command-note' down to configure options) then here is the DUY where that is done:
https://duy.retrokits.com/coder.php?guid=4f5764ec-e9eb-459d-8cac-049e50883244
I'll try to give a few pointers here: The training on boot is done by setting a flag to 'train mode' by default, a timeout on 'onHeartBeat()' (line 90) will reset the traninng flag after a few seconds, so does a note on message. A note off before the training flag is reset will trigger the 'set option mode' (line 101) and after that enters RK002 to normal operation.
on operation, if a command key is pressed (line 158) you just switch command mode and do things accordingly.