I think you could also configure some codes to work that way- like "set the value at this memory address to 0 when you press the button".
Incidentally, Game genie and Gameshark were the first time I realized I was committing piracy (or any crime), when I was asked to leave a store for writing down a code that was in one of those 10,000 Game Codes books. It's been a long sordid tale of hidden algebra notecards and microscopic formula sheets ever since.
This life of crime chose me.