It depends on the automotive company.

I can only speak for those I know of. Honda, for one, doesn't ship the keys at all. They have some sort of encryption device that determines the profile of the key. When it leaves the factory, they keep the serial numbers of the cars with the serial number of the key. At the dealer, the dealer can call to the factory with the serial number of the car and they give them the key numbers. Then the dealer can make the keys and the valet key at the dealership based on the serial number useing their encrypted key maker.

I believe (don't quote me on this) that Toyota ships their keys seperate from the cars.

Obviously, all this is done so that the car transport drivers don't sell off the valuable stock.