Kendrick Castillo – only days from graduation – acted fast inside of his British literature class at a suburban Denver school Tuesday afternoon. And he paid with his life.

When a gunman burst through the door at STEM School Highlands Ranch, barking at students to stay in place and not move, Castillo, 18, rushed the shooter. It was a quick-thinking move that fellow students said gave them a chance to bolt for safety or take cover under desks.

"Kendrick lunged at (the gunman), and he shot Kendrick, giving all of us enough time to get underneath our desks, to get ourselves safe, and to run across the room to escape,” senior Nui Giasolli told NBC's Today on Wednesday morning. Other students helped Castillo tackle the shooter, classmates said.

Colorado shooting:Teen who plans to become Marine tackled suspected shooter, father says

Douglas County Coroner Jill Roman confirmed Wednesday that the student killed was Castillo, the sheriff's department said in a tweet.

An emotional John Castillo lauded his kind-hearted son as a hero. “I want people to know about him,” he told ABC News.

He also told NBC that he talked with Kendrick about what to do in a school shooting, advising him "you don't have to be the hero."

But his son, who wanted to study electrical engineering in college, insisted he would act. "You raised me this way. You raised me to be a good person. That’s what I’m doing,'" Castillo recalled.

Castillo said the coroner told him his son, an only child, took gunfire that would have harmed other students, according to the Denver Post.

“He cared enough about people that he would do something like that, even though it’s against my better judgment,'' Castillo told the newspaper. “I wish he had gone and hid, but that’s not his character. His character is about protecting people, helping people.”

Castillo, a member of a Highlands Ranch robotics club called FRC 4418 Impulse, was set to graduate Friday, according to media reports, and was described as someone who was funny, smart and captivated by robotics.

"We're heartbroken by the death of Kendrick Castillo, a victim of the STEM School Highlands Ranch shooting," tweeted FIRST, a youth non-profit that advances STEM education. "Kendrick was a member of @Frc4418, of which his father is Lead Mentor. Our hearts go out to Kendrick's family, friends, & all affected by the shooting."

FIRST created a fund for Castillo's family and local FRC team 4418 in response to the outpouring of support in the community. More than $20,000 was raised in less than 24 hours, FIRST's Aaron Pickering said Thursday, and all proceeds will be distributed to the team.

More:Second suspect in Colorado school shooting is a girl, sheriff says

Castillo had been a four-year member of the school's robotics team and had several technology internships, according to his LinkedIn page, Buzzfeed reported.

Rachel Short of Bacara USA, a manufacturing business where Castillo began an internship last year, said he performed so well the company gave him a part-time job. Short said Castillo loved engineering and was eager to help people.

“To find he went down as a hero, I’m not surprised,'' said Short, the company's CEO. "That’s exactly who Kendrick was.”

Cecilia Bedard, 19, knew Castillo since elementary school and said he was always friendly and modest, frequently joining his father at Knights of Columbus fund-raisers and bingo nights.

“He was amazing,” Bedard said. “He was honestly the sweetest kid I ever met. Never said a mean joke.”

Douglas County Sheriff Tony Spurlock said investigators had not yet determined a motive for the attack that erupted shortly before 2 p.m. local time on Tuesday.

Two people were taken into custody, an 18-year-old male and a juvenile girl, the sheriff's department said.

The shooters were armed with at least two handguns and entered through a middle-school entrance at the K-12 school specializing in math and science, Spurlock said. Eight others were injured.

Contributing: Jorge L. Ortiz; The Associated Press