People say you’d have to be crazy to shoot up a school, but that’s not the case, not even most of the time.

While some perpetrators of mass shootings have certainly demonstrated signs of psychosis, most don’t. They are angry, aggrieved and violent, but not subject to involuntary commitment, leaving law enforcement and family members with few options for dealing with an individual whose behavior is worrisome and escalating. Even if someone makes a direct threat, that’s not always enough to take someone’s firearms away.

However, a solution already exists in a Maine law used to deter domestic violence. Subjects of protection from abuse orders temporarily lose the right to buy or possess firearms, and a growing number of states apply the same standard to other potentially dangerous people.

At least five states allow police or others to petition a court to temporarily remove firearms from individuals deemed to be a danger to themselves or others, and at least 24 states are considering such laws, including Maine, where a bill from Sen. Mark Dion, D-Portland, will soon be debated in the Legislature.

Red-flag laws, as they are known, allow people to intervene when an individual is exhibiting concerning behavior. A petition is brought before a judge, who can order the confiscation of the individual’s firearms for a short period, usually two to three weeks, after which the individual is given a hearing to challenge the order. These “community protection orders” typically run out in a year, but can be renewed.

Such laws put the focus on actions, rather than illness, for good reason. An analysis of 350 mass killers dating back a century found 22 percent suffered from psychosis. The prevalence in the general population is just 1 percent, so mental illness certainly can be a factor. But concentrating on it exclusively means a lot will be missed.

The Florida shooter, for example, may have been treated for depression, but that’s not enough to take someone’s firearms away. Nor would it be effective — or right — to impose such restrictions on the millions of Americans who are treated for anxiety or depression.

Red-flags laws have been used sparingly in the states that have them, as residents are not always aware of them, and police not always used to employing them, something lawmakers should consider as they debate Dion’s bill.

But while it’s impossible to know how many shootings these laws have prevented — and no one law is the answer — there’s evidence they have reduced gun violence. For one, studies have shown that the similar domestic violence laws have likely stopped shootings.

And the red-flag laws have been used not only to take firearms away from individuals threatening others, but also from those threatening to hurt themselves. Not only has that prevented some suicides — about 70 in the 19 years the law has been on the books in Connecticut, according to a study at Duke University — but with suicidal ideation being one warning sign of violent outbursts, it may have prevented other kinds of violence as well.

Red-flag laws have also been used on people suffering from dementia, alcoholism and other health issues in order to defuse situations of short-term danger when there is no other avenue.

After each mass shooting, people wonder what could have been done. Unless the perpetrator was a felon, convicted of domestic abuse, or seriously mentally ill, the answer unfortunately is not much. Red-flag laws can change that.