How it works
を (object) marks 鍵 (key) as the thing the action happens to. The verb is なくす (lose), and here it takes the polite past form なくしました (lost): the polite 〜ます (polite) ending shifted into its past, 〜ました (polite past). As always in Japanese, the verb comes last.