Look for interrupt on change. But you may need to change your current hardware.