I need help with a little code entry pad.

how am i meant to compare the the state with oldstate before its even made

Because it contains the state of the switches the last time round the loop so you can comparison it with this time round the loop and see if you have anything changed.