if you are going to change the keypad, let him know. just tell him that if he chooses to leave, then you will change the locks/keypad for your own feelings of security. to do it without his knowledge will only aggravate the situation, and will not help in the long run. it may be legal, it may give you some temporary satisfaction, but it may not be worth the fallout.
in your position, its tough to separate whats done on emotions and whats done on logic. i dont know how to tell you how to determine which is which. its something you need to keep reminding yourself. maybe look at it and think about "Will it give me temporary satisfaction but hurt me in the long run?"
whats very important in all of this is that you do not stoop to his level, or you do not lose who you are, dont be vindictive. dont be petty and small minded. now is not the time for revenge. Protect yourself from the damage. Dont do anything that may make you feel good because it hurts him, but that you may live to regret it later. Always choose the high road. dont give him anything that he can use to justify his decisions - and he will use the smallest most ridiculous things.
He will do enough damage to himself, others will find out and will judge him. He will lie about you and your relationship. Let him. people will know the truth. he will need to live with the outcome of his choices.
after this is all done, whichever way it goes, you will need to live with yourself and your choices. be very thoughtful to not do anything you'll later regret.
i dont believe possession is the right way to look at this. Possession implies that it was out of his control. He made the choice 3 or 4 years ago to have an affair. i believe it was this choice that made him change, whether it was guilt or having to sneak around or the pressure of hiding his affair. i think it's the choice that causes the change, not the other way around. He's an adult and he should deal with the consequences of his actions without hiding behind excuses.
again, trust your lawyer, and do what he says. protect yourself financially. dont do anything that can be used against you.
"In a ham and eggs breakfast, the hen is involved, but the pig is committed".