Or - if you can tolerate a little latency -

You can use a fast timer interrupt (say 1mSec) and check the status of any pin in that interrupt.