According to an Airbus video describing the operations of locking the cockpit door, it is locked by default when closed. But when a pilot wants to lock the cockpit door to bar access to someone outside, he or she can move the toggle to a position marked “locked,” which illuminates a red light on a numeric code pad outside. That disables the door, keypad and the door buzzer for five minutes.
While these functions are disabled, the video shows, the only way to make contact with the crew is via an intercom. The doors can then be opened only if someone inside overrides the lock command by moving and holding the toggle switch to the “unlock” position.
If someone outside the cockpit suspects the pilot is incapacitated, that person would normally first try to establish contact via the intercom or by activating a buzzer. If those efforts were unsuccessful, the video shows, a crew member outside the cockpit would need to enter an emergency code on the keypad.
The code activates a loud buzzer and flashing light on the cockpit control panel, and it sets off a timer that unlocks the door 30 seconds later. The person outside has five seconds to enter before the door locks again.