What is the nature of the right? It is to keep and bear arms. That defines it's limits. Within the narrow confines of what arms are, we have an absolute right to keep and bear them.
Now, if a person is mentally deranged in such a way as to present an immanent danger to the lives of others, we have two competing rights in conflict, viz., on the one hand, the deranged man's right to be armed, and on the other, the right of the rest of us not to be placed in immanent and reasonable fear for our lives, by the judgment of a reasonable and prudent person. Thus, if a jury of the deranged man's peers determines that his possession of a firearm places the rest of us in immanent and reasonable fear for our lives, then we (society) are justified in taking action in our self-defense, i.e., either killing him or removing his weapons from his possession. He still retains the right, but it is temporarily subordinated to our right of self-preservation in the face of immanent threat.
You see, it's not so hard when you apply basic common sense. By the way, the very same reasoning applies to violent criminals. Notice, however, that a man's right to keep and bear arms gives way to our right to remain alive only so long as the threat to our lives and limbs remains immanent. In the case of a violent criminal, that will be determined by the parole board or the judge. In the case of the parole board, they make this determination based on current facts, in the case of a judge, he makes the determination in advance, e.g., he predicts that in 10 years, the danger to society will have dissipated enough so that the criminal will no longer be an immanent threat to our lives and limbs. A death sentence is a determination that the criminal will never cease being an immanent threat to our lives and limbs.