Ceramic bypass/decoupling capacitors are often better .

IOC flags on pushbuttons are used to swap values left to right, then WRITE back to memory
a particularly bad practice, you should always check that it was an actual keypress [ in that was held for a definitive time] before actioning it

key activity should be ignored until power is stable