"Dial M for Murder's" narrative is a masterclass in plot construction and reversal. The central twist is not the identity of the killer, but the failure of the planned murder. When Margot kills her attacker, Charles Swann, in self-defense, Tony's 'perfect' plan is shattered. In a moment of brilliant improvisation, he engineers a Plan B: framing Margot for premeditated murder. He plants a letter from her lover, Mark, on Swann's body, fabricates a story that Swann was blackmailing her over the affair, and hides her stocking (which he claims Swann used to strangle her) in her sewing basket to be 'discovered' by the police. His manipulation is so successful that Margot is found guilty and sentenced to death.
The resolution hinges entirely on the latchkey. Tony had taken Margot's key from her handbag to hide for Swann. After the murder, he retrieves what he thinks is the same key from Swann's pocket and returns it to the handbag. However, Hubbard brilliantly deduces that Swann had returned Margot's key to its hiding place under the stairs and the key Tony found was Swann's own. To prove this, Hubbard lays a trap. He has Margot released from prison and brought to the flat. She tries her key (Swann's key) from her handbag, and it doesn't work, proving she is unaware of the hidden key. Later, when Tony needs to enter the locked flat, he finds the key in the handbag doesn't work. His guilt is sealed when, in a moment of hubris, he uses the hidden key he planted, revealing his knowledge of the entire conspiracy to the waiting Inspector Hubbard and Mark. The final shot shows him coolly pouring a drink, defeated but maintaining his gentlemanly facade to the end.