Having an extra copy of your car key is a precaution everyone should take. If you lock your keys inside the car an extra set will save you the time and expense of having a locksmith retrieve them for you. An extra set can also be shared with a secondary driver in the family so you don't have to loan out your entire set of keys. Copy your keys before you lose them, and keep them in a safe place. A dealer can get replacement keys for you with proof of ownership, but it may take days to create the copy.
Your car dealer can make an extra set of keys for your car. This may be your best option if your key has a transponder antitheft system - where the key sends an electronic signal to the car identifying itself. If your key has a large plastic head, its got a transponder. Call ahead to your dealer to make an appointment and check if they have your key in stock. If you have an older car, the key may have to be ordered.
Standard keys - those without the antitheft device - can be copied at your local hardware store or the auto department of a discount store. Check your spare key after purchasing to make sure it works correctly.
Get an emergency key. Plain hardware store copied keys are less expensive to make than antitheft keys. Even if your car has an antitheft device, consider making a plain copy for emergency lockouts. A plain copy will only work on your door and boot, but that might be enough help if you've locked your keys inside the car.