US President Donald Trump speaks to the press as he departs the White House in Washington, DC, on August 7 2019.

President Donald Trump on Wednesday said that he will bring lawmakers back to Washington from their August recess if Republicans and Democrats can "get close" on a gun reform proposal.

Trump, en route to visit the Ohio and Texas cities in which back-to-back mass shootings over the weekend left 31 dead, also pledged his support for background checks and "red flag" laws preventing mentally ill people from accessing firearms.

"We're going to see where we are. We're dealing with leadership right now. And you know, you have two sides that are very different on this issue. And let's say all good people, but two sides are very different," Trump told reporters outside the White House.

"If we get close, I will bring them back, but it has to be -- you know, we have to see where we are with leadership. Normally, this has been really a decision -- Congress gets together and they try to do something, but if you look over the last 30 years, not a lot has been done," Trump said.

The president and first lady Melania Trump were traveling to Dayton, Ohio, and El Paso, Texas, to meet with first responders, survivors and victims' families following the two deadly mass shootings. Some Democrats, including presidential candidates such as former Texas Rep. Beto O'Rourke, have said that Trump's rhetoric bears at least some of the blame for the shootings.

Trump tweeted in response that O'Rourke "should respect the victims & law enforcement - & be quiet!"

Trump TWEET

A gunman toting an AK-47-style assault rifle and extra magazines of ammunition killed 22 people and injured dozens more at an El Paso Walmart on Saturday morning, after apparently posting a racist screed on an anonymous online messaging board. Police have detained suspect Patrick Crusius, a 21-year-old white male.

The Dayton gunman, armed with an AR 15-style rifle, killed nine people in an entertainment district hours later, including his own sister. That shooter, identified as 24-year-old Connor Betts, was killed by officers less than a minute after his attack began, police said.

Trump told reporters Wednesday that he supported background checks for gun purchases.

"I'm looking to do background checks, I think background checks are important," he said. "I don't want to put guns into the hands of mentally unstable people or people with rage or hate, sick people. I'm all in favor of it."

He added that "I think both Republicans and Democrats are getting close" to "doing something on background checks."

In fact, the Democrat-led House passed a gun control bill that would strengthen background checks months earlier, but Senate Majority Leader Mitch McConnell has not brought the legislation to the Senate for a vote.

In a statement Monday, McConnell said that "Only serious, bipartisan, bicameral efforts will enable us to continue this important work and produce further legislation that can pass the Senate, pass the House, and earn the president's signature. Partisan theatrics and campaign-trail rhetoric will only take us farther away from the progress all Americans deserve."

Neither a spokesman for McConnell nor the White House immediately responded to CNBC's inquiries about the president's comments.

Many Republicans have signaled their support for red flag laws, also known as extreme risk protection orders. But Senate Minority Leader Chuck Schumer, D-N.Y., said in a statement Wednesday that without "strong universal background checks" in place, red flag laws alone "won't be fully effective."

"The notion that passing a tepid version of an Extreme Risk Protection Order (ERPO) bill—alone—is even close to getting the job done in addressing rampant gun violence in the U.S. is wrong and would be an ineffective cop out," Schumer said.

Trump also said there was no "political appetite" for legislation to ban assault weapons. A federal assault weapons ban had been signed into law in 1994 by President Bill Clinton, but was allowed to expire in 2004 under President George W. Bush.