RELATED: TIMELINE: How Florida high school shooting unfolded
Nineteen-year-old Nikolas Cruz was wearing an orange jumpsuit with his hands cuffed at his waist during the Thursday afternoon hearing. His attorney did not contest the order and had her arm around Cruz during the brief court appearance.
Cruz is accused of opening fire Wednesday afternoon at Marjory Stoneman Douglas High School in Parkland, killing 17 people.
RELATED: How to help those impacted by the Florida high school shooting
Law enforcement officials told The Associated Press that Nikolas Cruz legally purchased the assault weapon used in the attack.
As reactions poured in Thursday, President Donald Trump focused on the young man's mental health, and Attorney General Jeff Sessions said he wants the Justice Department to study how mental illness and gun violence intersect, to better understand how law enforcement can better use existing laws to intervene before these school shootings happen.
RELATED: Here are the victims of the Florida school shooting
"It cannot be denied that something dangerous and unhealthy is happening in our country," Sessions told a group of sheriffs in Washington. In "every one of these cases, we've had advance indications and perhaps we haven't been effective enough in intervening."
Republican Florida Gov. Rick Scott said he's already told House Speaker Paul Ryan that "if someone is mentally ill he should not have access to a gun." Broward County Schools Superintendent Rob Runcie said "now is the time to have a real conversation about gun control legislation," and said that if adults can't manage that in their lifetimes, he said students will do it.
VIDEO: Trump cites mental health in shooting, no mention of guns
Broward County Sheriff Scott Israel called for giving law enforcement more power to detain people who make threats.
"What I'm asking our lawmakers to do is go back to places like Tallahassee and Washington, D.C., to give police the power," the sheriff said, to detain people who make graphic threats or post disturbing material online, and bring them involuntarily to mental health professionals to be examined.
RELATED: What we know about Florida school shooting suspect Nikolas Cruz
The sheriff said law enforcement can certainly visit gun owners whose mental health is questioned, "whether they have a gun legally or not."
Thirteen wounded survivors were hospitalized, including two people in critical condition. The sheriff said some bodies remained inside Marjory Stoneman Douglas High School as authorities investigate the crime scene. The slain included a school athletic director and another adult who worked as a monitor at the school. Runcie called them heroes.
Cruz was ordered held without bond and booked into jail early Thursday, still wearing a hospital gown after he also was treated, for labored breathing. The jail said he is 5-foot-7 and weighs 131 pounds.
His former classmates thought they were having another drill when a fire alarm sounded, requiring them to leave their classrooms Wednesday.
That's when police say Cruz, equipped with a gas mask, smoke grenades and magazines of ammunition, opened fire with a semi-automatic weapon, killing 17 people and sending hundreds of students fleeing into the streets.
It was the nation's deadliest school shooting since a gunman attacked an elementary school in Newtown, Connecticut, more than five years ago. The overall death toll differs by how such shootings are defined, but Everytown For Gun Safety has tallied 290 school shootings in America since 2013, and this attack makes 18 so far this year.
VIDEO: Student at school where shooting happened: 'Everyone predicted this'
Trump lamented in a tweet that there were "So many signs that the Florida shooter was mentally disturbed, even expelled from school for bad and erratic behavior. Neighbors and classmates knew he was a big problem. Must always report such instances to authorities, again and again!"
Trump also issued a proclamation saying, in part, "Our Nation grieves with those who have lost loved ones," and planned to address the nation about the shooting. Pope Francis sent a telegram of prayer and condolences, and the New York Stock Exchange held a minute of silence after its opening bell.
Cruz legally purchased the AR-15 used in the attack about a year ago, law enforcement officials told The Associated Press. The officials, not authorized to discuss this publicly, spoke on condition of anonymity. Federal law allows people 18 and older to legally purchase long guns, including this kind of assault weapon.
Authorities offered no immediate details about a possible motive, except to say that Cruz had been kicked out of the high school, which has about 3,000 students. Students who knew him described a volatile teenager whose strange behavior had caused others to end friendships with him.
VIDEO: GRAPHIC: Harrowing video shows students cowering as gunshots ring out
Cruz's mother Lynda Cruz died of pneumonia on Nov. 1 neighbors, friends and family members said, according to the Sun Sentinel . Cruz and her husband, who died of a heart attack several years ago, adopted Nikolas and his biological brother, Zachary, after the couple moved from Long Island in New York to Broward County.
The boys were left in the care of a family friend after their mother died, said family member Barbara Kumbatovich, of Long Island.
Unhappy there, Nikolas Cruz asked to move in with a friend's family in northwest Broward. That family agreed and Cruz moved in around Thanksgiving. According to the family's lawyer, who did not identify them, they knew that Cruz owned the AR-15 but made him keep it locked up in a cabinet. He did have the key, however.
Attorney Jim Lewis told the AP that the family is cooperating with authorities, and had no idea he was planning the shooting.
VIDEO: School shooting witness: I heard too many gunshots to count
He seemed like "just a mildly troubled kid who'd lost his mom" during the three months they lived together; respectful and quiet, but also sad because his mother had died, Lewis said.
They had "no indication that anything severe like this was wrong," Lewis said. "He totally kept this from everybody."
Lewis also said the family was not aware of any other weapons in the gun cabinet he had, and couldn't talk about how long they knew of the AR-15 because people are looking to sue them now. Photos posted in an Instagram account linked to Cruz show a half-dozen weapons displayed on a mattress and a box of ammunition.
Victoria Olvera, a 17-year-old junior, said Cruz was expelled last school year because he got into a fight with his ex-girlfriend's new boyfriend. She said he had been abusive to the girl.
"I think everyone had in their minds if anybody was going to do it, it was going to be him," said Dakota Mutchler, also 17.
RELATED: Worst mass shootings in recent U.S. history
Cruz was taken into custody without a fight about an hour after the shooting in a neighborhood about a mile away. He had multiple magazines of ammunition, authorities said.
The sheriff said 12 bodies were found inside the building, two more outside, and another a short distance away from the school.
Hearing loud bangs as the shooter fired, many of the students hid under desks or in closets, and barricaded doors.
"We were in the corner, away from the windows," said freshman Max Charles, who said he heard five gunshots. "The teacher locked the door and turned off the light. I thought maybe I could die or something."
Charles said he passed four dead students and one dead teacher on his way out, and was relieved to finally find his mother.
"I was happy that I was alive," Max said. "She was crying when she saw me."
Click here for full coverage on the tragedy at Marjory Stoneman Douglas High School in Parkland and click here for a look at comprehensive coverage on school shootings here in the Bay Area and across the country.