We humans have built pretty much everything into weapons over time, and here's an example of that. There are a variety of types of key pistols in existence, varying from the elaborate and complex to the ones as rudimentary as this one. This example is simply a large(ish) key with the stem hollowed out so that a powder charge and projectile can be loaded into it. A touchhole is drilled at the back of this chamber, where a lit ember can be used to ignite the powder and fire the charge.
Unfortunately, I don't have any specific history on the date or origins of this example...