Who knew it would be so difficult to replace my car keys? Electronic keys are not as simple to replace as other car, home or other keys. If you don't already have a spare, you might want to get one before you need one, I know by experience you do not want to get caught without a key.
What you will need:
A local lock smith could do my key for $60, $40 less than the dealership. The dealership charged $50 for the key and $50 for the programming. This can be reduced if you buy the blank key online.
My key broke as I left church on Sunday. It took all of Monday to get my key. After looking for the best deal, getting a tow, procuring a ride, waiting for the car maker's website to come back online and driving to the dealership. It took me a full day's work to get my key. Learn from my mistake ;-)
Ace Hardware stores makes electronic keys for about $10-15. I went there with a friend to make a copy of his key, and it turned out his was not electronic, so it only cost $3-4, but if he had needed an electronic key it would have cost only about $10 or so. Try a hardware store that makes keys - it looks like they're much cheaper than a dealer or a locksmith. It also pays to leave a copy with a trusted friend or neighbor; my friend has copies of my keys, and I have copies of his. It has helped us both a couple of times.
I agree that electronic keys are difficult to replace. They also have to be reprogrammed, which is not that difficult if you know how to do it (my son does, and told me, but sadly, I've forgotten!). I think you need the original key to do this. My dealership, because I was good customer, did it for me free of charge.
I also had a regular blank made that will open the door of the car (if you have a keyhole - some don't now), just in case I lock the key and electronic door opener in the car. I can use this key to get in, but not to start the car. It is worth the extra cost to have a spare key or two.