You have to
modify your original program (a) to check the
status of your burglar-alarm switch. A modified
version checks the state of the switch only after
you activate a key (b). A better solution is to
check for the state of the door every time you go
around the loop that tests to see if a you have
pressed a key (c).