There are 2 ways this is typically done.
In the first case the door is always locked, but the striker plate is electrically operated and when the door is "unlocked" the striker plate allows the door to be opened. The benefit here is that when electrically locked, the key will open the door.
The other case is where a large magnetic stopper is attached to the face of the door and whilst the door itself is not locked, the huge magnetic attraction means you can't open the door -- even with the key.
Here is a place that sells both types (and probably others that I'm not familiar with).