I have a rather complex program but faced the same problem. One answer is to test the pin regularly. Use let b0=pins. Then mask out the undesired pins with an AND eg b0=b0 and %00100000. Load the previous state of the pin in b1 (I poke/peek to ram as I want to use the registers in other ways. Then store the new value to that ram location ready for the next test.
Finally, with all the 'housekeeping' out the way, do some tests. The values are in b0 and b1, so to test if they are different use xor, eg b2=b0 xor b1. Look up the truth table for the xor function on wikipedia. Actually, look up OR, AND, NOR and NAND as well as these are all useful.
To test if the new value is high and the old value was low, use if b0>b1 then...
To test if the new value is low and the old value was high, use if b1>b0 then...
To test if the values are both the same (ie most of the time), if b0=b1 then...