The usual procedure for recoding a key fob after battery replacement involves switching the car to "program" mode, pressing a button on the fob and turning off the ignition. Referring to the vehicle's manual can help determine the appropriate way of recoding a particular car.
Recoding a key fob involves synchronizing the car with the fob so that the codes that the fob sends prompt the car to perform certain actions such as locking and unlocking the doors, and opening the car trunk. Other than battery change, other factors that may necessitate key fob recoding include a damaged key fob and multiple pressing of the fob buttons while it's out of sequence.
To avoid out of range security issues, the car owner should recode the key fob from inside the car. Start by inserting the car key into the ignition switch and turning the ignition to "On," being sure not to start the engine. If necessary, turn the key on and off multiple times until the car switches to "program" mode, usually denoted by a light flash. Press the key fob button to recode the fob to the car. Follow up by turning the ignition to "Off" and exiting the vehicle before testing the recoded key fob.