Sometimes dealers will try to get a deposit solely to keep you at the dealership or to wear you down until you agree to purchase. There are only 3 times you should ever have to give a deposit on a vehicle.
The first is if the dealer doesn't have the car in stock but is willing to swap vehicles with another dealer (called a dealer trade), the second is if the dealer special orders a car for you from the factory, and the third is to hold a vehicle for a certain amount of time AFTER you've negotiated the price.
Although I don't recommend doing a dealer trade, if you do, make certain the dealer has located the exact vehicle they will be trading. Have them write down the VIN # and the exact specifications of the vehicle.
Sometimes dealers will lie just to string you along until they (hopefully) locate a vehicle for you. This usually happens with cars that are in high demand and low supply, so don't ever leave a deposit unless they can show you the exact vehicle and the date it will arrive.
If you're ordering a car directly from the factory, you will be required to leave a deposit. There's usually no shenanigans involved here - but make sure you read the fine print carefully. The deposit may not be refundable if you change your mind.
Lastly, a dealer may ask for a deposit to hold a vehicle for you after a Purchase & Sale Agreement has been signed. They want to make sure you're serious about buying the car before they will agree to hold it for you. This only happens if you need time to gather payment for the vehicle or take out a loan. Usually, this is legitimate, but make sure you're leaving a fully refundable deposit and not a partial payment.
Some dealers will have you sign a form with the "deposit" listed under "partial payment". Don't sign that unless you are absolutely certain you will buy the car.
You should always leave deposits using a credit card. You can always dispute the charge through the credit card company and it just makes getting a refund less of a hassle.