Whether correct legally or not, it is ridiculous. You leave your friend's party get in your car, put the key in, then you make the wise decision that you have had too much to drive. However, you are impaired enough not to think to remove the keys. Sure, you could have gone back in and slept on your friend's couch, but what if it was a bar you left and that isn't an option?
You did the right thing and still get ******.
http://www.dui-pa.com/Basic-DUI-Questions.shtml
Q: Does the car have to be moving for me to be guilty of DUI?
A: No. You do not need to have actually operated the car in order to be arrested. Believe it or not, you can still be found guilty of a DUI if you had the capability and opportunity to operate the vehicle. It does not matter if you exercised that capability or opportunity at the time of the arrest. In other words, you can be charged with a DUI for sitting behind the wheel of your car with the keys in the ignition.
while this is for the state of Pennsylvania, it's probably a fairly common law.