Key guns were first used back in the 16th century as a way for jailers to defend themselves while opening and closing cell doors. While the standard pistol of the time makes more sense, key guns were interesting pieces of gun history nonetheless. Key guns were actually fully functional tools, they were both a key and a functional pistol. Some of key guns made use of a flintlock mechanism, others a percussion cap, and the most basic a touch hole where the user would have to use their cigar to light the charge.
While they may not have been the most lethal firearm at the time and were pretty odd-looking, key guns did serve their purpose. I’d imagine they were used more so to stun or scare an attacker rather than actually kill them. Or they could have just been an old-time marketing gimmick, like how every gun company is marketing a zombie product today.