Saving a switch input to choose mode of operation

This is working for a Serial input with my keyboard. But I have a membrane keypad switch for the input. Is there a buffer or read program for that? I will search for one or am I overthinking it?