Much as it sounds. A code that happens, activates if you will, as a result of a button press.
More advanced cheat systems gain the ability to read one area of memory and then do actions based upon it equalling something, less than/greater than and all the other fun things you get in programming classes.
The states of buttons then are mapped to memory somewhere* so your cheat engine can read these every time the cheat update aspect is run (usually once a frame) or lower level code if you do that. It then sees if the button (or combination thereof) matches a pattern and you can then say write full health in and in doing so dodge things like fights only get won when you get to low health/have to lose this fight/can keep some challenge in the game but have a get out of jail free/can find the potion counter and instead make a drink potion command by filling the health a potion worth and subtracting one from the counter rather than fiddling with menus.
*in best practices programming this is not ideal to use because of the switch bounce problem. If you have ever had a computer mouse start to die on you and double click accidentally then this is that taken to the failure point but as it is a mechanical device it happens at lower levels too (bit of spring, bit of oxidation to push through, bit of welding together...) from one millisecond to the next. Short version is every frame the state of the switches is copied to another area and all the code behaving properly should be using that instead, does not solve truly broken controllers but does mean code reading in the same frame but a few instructions apart will not have different results from the controller and cause unexpected behaviours.
Cheat documentation (
https://web.archive.org/web/20191123185758/https://doc.kodewerx.org/hacking_nds.html ) for systems that support this sort of thing (older systems tend to have far simpler cheat options that might only be able to just write things and not do anything fun, though some setups will have a button on the cheat cartridge to turn things on and off, or activate things) will usually make an effort of noting where the controller states are located in a given system, and you might even find programs that calculate certain combos for you rather than playing with sometimes arcane documentation
http://problemkaputt.de/gbatek.htm#gbakeypadinput
If your button activator code can say write a bit in memory somewhere that the game will take as a signal to use its held item next frame regardless of what it might normally have done then you have a code. However for something as usually time sensitive as items like this then that is harder for as mentioned it probably all lives and happens in CPU registers and flags which is harder for conventional cheats to mess with (if you are making a cheat that edits the code the game runs on then different matter). Normally I would expect to see it more for something automatically happening that you might want to stop (don't drink all my nice potions automatically, just when I say sort of thing so you make it appear as zero for its purposes and restore later/when you want one drunk) but I can't rule it out, or a functional equivalent.