How-To: Self Programming Keys and Remote

Mazda 6
I have a 2009 mazda 6 JDM car. I lost the only key that I got when I purchased the car. If I buy 2 keys from ebay, how will I be able to program the new keys?
2012 mazda 6i
Hi, I'm new to this forum. I've never had a key like this before.
I am also trying to have a spare as the previous owner just had one switchblade. What is the difference between the section on "remote programming" vs "key programming"
I ask because I want to be clear on whether the "key programming" is done to properly "activate" the transponder chip???
so if you don't mind please it as clear as you are able - thank you for your help

Have seen a few posts asking how to program keys/remotes without going to the dealer. Im posting programming instructions for both. Please note you will need 2 working keys to program them. Remotes it doesnt matter if you have any or not...
NOTE: this is only for switchblade style and seperate key/remote fob only. Will not work with credit card type keys/remote.

Remote programming instructions

Step 1: Open drivers door and leave open.

Step 2: Lock and unlock the drivers door using the power door lock switch on the door.

Step 3: Insert key into the ignition.

Step 4: Turn key to on position and return to off position. (IMPORTANT - use ON position NOT ACC position). Do this 3 times within 10 seconds. Leave key in the ignition.

Step 5: Open and close the drivers door 3 times. (Door should be left open after this step).

Step 6
: ECU should respond by locking and unlocking the doors.

Step 7: Press any button on remote #1 twice. ECU responds by locking and unlocking the car doors.

Step 8: Press any button on remote #2 (etc.) twice. Each time the ECU will respond by locking & unlocking the doors.

Step 9: Remove the key from the ignition and the ECU will respond a final time with a series of door locks and unlocks. You're done!

Key Programming Instructions

The timing is critical to this procedure, please read through the entire procedure before attempting.
1. Insert one of the pre-programmed transponder keys and turn the ignition to "on", leave on for at least one second (I wait until the red key symbol in the instrument cluster extiinguishes), remove the key from the ignition.
2. Within 5 seconds insert the second pre-programmed key and turn the ignition to "on" for at least one second but no more than 5 seconds (use the key symbol for this as well) then remove the second key.
3. within 10 seconds insert the new key in the ignition and turn the ignition to "on", if you are successful the red key symbol will illuminate then extinguish after about a second.

If you are not successful the red key symbol will flash repeatedly to indicate that you have inserted an invalid key. Remove the key, wait a minute and try it again, it took me a few times to get it perfect and I had done it before.
2015 Mazda 6 Sport
Hi. Thank you for the instructions! I recently got a used 2015 Mazda 6 Sport (Manual Transmission), basic model. Are there any instructions on the programming the key? This is not a keyless entry, but was wondering to see if I can program the car/remote to alert for head lights on? My previous car had this, the car will continue to beep if the lights are on (if the engine is off and with the door open).

Any help is appreciated!