President Donald Trump said on Thursday he supports meaningful background checks for gun buyers, but he told reporters that those responsible for recent mass shootings were mentally ill and the United States should build more mental institutions.

Trump said he had been speaking with Senate Majority Leader Mitch McConnell and many other Republicans about the problem of gun violence and that "they don't want to have insane people, dangerous people, really bad people having guns."

"We don't want crazy people owning guns," the president added. "It's them. They pull the trigger. The gun doesn't pull the trigger. They pull the trigger. So we have to look very seriously at mental illness."

The president is under pressure to curb gun violence following mass shootings that killed dozens of people this month in Texas and Ohio. His comments came as he started a trip from New Jersey to speak to a campaign rally in New Hampshire.

"We're looking at the whole gun situation," Trump said when asked whether he was pressing Republicans on tougher background checks for gun buyers.

"I do want people to remember the words mental illness. These people are mentally ill. ... These are mentally ill people and people have to start thinking about it. I think we have to start building institutions again," he said, adding that many U.S. mental institutions were closed in the 1960s and 70s and their patients released onto the streets.

"A lot of our conversation has to do with the fact that we have to open up institutions," Trump added. "We can't let these people be on the streets."