Because of this, I recommend that the door lock is checked for working, and used at least every month to avoid this situation if/when it happens.
However, if this does happen to you, you will find that there's a jump start point under the bonnet, which in the event will power up the starter battery if connected to a 12v source (another vehicle or battery with jump leads.
Unfortunately, this does nothing for the aux battery which is isolated from the starter battery until the ignition is turned on, and the engine is started. Obviously this isn't possible whilst you still can't open the drivers door, but can be done if you gently prise out the quarterlight window, put the correct key in the ignition, and switch on. This will automatically deactivate the deadlocks, and you can then unlock open the door using the inside opening lever. At this point you can replace the dead battery (or batteries), and ideally, replace the non-functioning keylock in the door.
If you don't fancy prising out the window, you could try the method below, discovered by TripleSix, but firstly, be aware that you can do some damage messing with open bits of wire and electrics if you don't take care, or aren't confident, and also be aware that this won't work if BOTH batteries are dead, unless you apply power to the jump start point simultaneously.
I HAVE NOT TRIED THIS METHOD MYSELF, YOU DO SO ENTIRELY AT YOUR OWN RISK or ask an autospark to do it for you

TripleSix wrote:You need a 6 inch long piece of electrical wire, bared on both ends.
Open the bonnet, and expose the jump start point which is on the engine side of the engine bay fuse box.
Open engine fusebox, bottom left is the fuse for the electric fan, pull this fuse out.
Use the wire to put power from the jump start point to the fan fuse terminal ( I can't remember which side!)
This will power up the front battery enough to let you unlock the doors with the keyfob.