Memorize

If I understand the question correctly, you want to use EEPROM:

That way you can store up to 1K bytes (which should be plenty) of "button codes".

I can't quite visualize the hardware, but the gist of it sounds OK. The "programming" button would get it to save incoming sequences into RAM, and then if you "commit" them they are saved in EEPROM, which survives power-off.