The mechanical use in a pen would be the spring and the stopper which does not let the spring come out until the button is pressed
The mechanical parts of this is probably gears and a driver gear which makes the lock come in and out. The driver gear is driven by the key we use and the key is the only type which can be used.
The picture is of a door hook and which uses joints to move itself.
The spectacle is another type where the pivot helps it to not be so flimsy.
The picture which I would think of a better solution. The door is only attached by two screw-like structures at the top and bottom of the door. As a result of which, the strength of the door is not so good. The degree of turning is not stopped so the door is easily a obstruction as it can turn more than 110degrees. This affects any papers or anything placed near the door as it can crumple the paper as it is not stopped from turning. I would say that they should have something to stop the door from moving so freely.
This works as when the wheel is nearer to the handle it moves back because of the weight, however when it is further away the Duck moves forward.
How it works:
When open, the magnets retract the rods so that they do not dangle around.
When in use, the hollow rod lets the thinner rod go in and that would make the structure strong enough to bear the weight