Henrik has suggested one possibility. Another is to use a XOR function.

The simple pseudo code for this would be
Code:
MyLoop:
        Keys = Read_switch_now
        if (PrevKeys XOR Keys) then
            gosub KeysHaveChanged
        endif
        PrevKeys = Keys
goto MyLoop
Cheers