They are all different, so do a google search and you will probably find a website where someone has posted the answer. It can be a fairly time consuming and irritating process, depending on how many steps are required and how many items the key fob operates.
here's how it was for the ex gf's toyota (well, it was similar to this anyway
Turn on key
open and close driver door 3 times.
Turn off key.
Open and close drivers door 5 times.
Turn on key.
Open and close drivers door 5 times.
Turn on headlights.
open door
turn off headlights
close door
turn key on and off 3 times.
Some of them have elaborate procedures for each feature, like the Toyota described above, some you just hold up against one part of the dash where the sending unit is located and press the lock button for a few seconds, some have other ways of programming.
Here's the procedure that I described from the above link. OK, so my memory was faulty, but it's still goofy as hell.
1. Start with the key out of the ignition, drivers door is open all others closed and
drivers door is unlocked.
2. Perform these steps within 5 seconds.
A. Insert the key into the ignition(Do NOT Turn) Pull key out.
B. Insert the key into the ignition(Do NOT Turn) Pull key out.
3. Perform these steps within 40 seconds.
A. Close then open the drivers door.
B. Close then open the drivers door.
C. Insert the key into the ignition(Do NOT Turn) Pull key out.
4. Perform these steps within 40 seconds.
A. Close then open the drivers door.
B. Close then open the drivers door.
C. Insert the key into ignition and leave it in ignition.
D. Close the drivers door.
E. Turn the ignition to ON (Do NOT Start) then back to OFF.
F. Remove the key from the ignition.
5. Within 3 seconds, the power door locks should lock then unlock automatically
indicating successful entry into programming mode.
Return to step 1 if the locks do not cycle at this point.
6. Perform these steps within 40 seconds.
A. Press the lock and unlock buttons on the remtoe simutaneously for 1.5 seconds.
B. Immediately after letting go of the lock and unlock buttons,
Press the lock button by itself and hold for 2 seconds. Within 3 seconds, the door
locks should lock and then unlock once indicating successful programming. If
the door locks cycle twice, repeat steps A and B in step 6 as the remote was
not accepted.
C. Repeat steps A and B in step 6 for each new remote.
Believe it or not, that is nothing compared to this Toyota Camry I bought from a customer. There are all those steps above, or very similar, plus 10 or 12 choices depending on whether you want the horn to beep at different times, a panic mode, the headlights to go on for a few seconds when you open the doors, whether it has an automatic trunk opener or not, and a few others.