You are indeed talking about
A strange thing hangs under a man's clothes.
It is an oddly shaped piece of metal, which is often hung with a chain around a man's belt loops. (In the 18th century, this must be the norm, I suppose)
It is long and firm, pierced in front, and has a good fixed place.
It usually has a hole at the head for the keychain to pass through, keeping it in a fixed place (somewhat). It is often a few inches long, made of strong metal.
(Thanks to @alexander for deciphering this next clue) In the olden days, keys used to have a piercing in the front, which would match a similarly shaped pin inside the lock.
When a man lifts his garment, it is because he wishes to visit with the head of this dangling instrument the familiar hole which it has, when of equal length, has often filled before.
A man reaches for his key when he wants to unlock the lock pertaining to that key. The hole in the lock should match the length and pattern of the key exactly to be able to unlock the lock.