People attend a vigil for the victims of the shooting at Marjory Stoneman Douglas High School, in Pine Trails Park in Parkland, Florida. Picture: Monica McGivern/Xinhua

Parkland, Florida - As soon as she heard "Code Red Lockdown" on her radio in a Florida high school library, Diana Haneski remembered how a fellow librarian saved lives by locking 22 people in a supply closet during the massacre at Sandy Hook Elementary School.

"She was there that day in Sandy Hook and because of her I knew what to do," said Haneski, a library media specialist at Marjory Stoneman Douglas High School in Parkland, Florida, where a former student is charged with shooting dead 17 people on Wednesday.

Her longtime friend Yvonne Cech was the librarian on duty at the Newtown, Connecticut school five years ago when a gunman, also a former student, massacred 20 children and six adults. Cech's husband Michael said she scrambled 18 children and four adults into a small closet and locked the door as gunshots rang out.

Haneski told Reuters on Friday that as soon as she heard the lockdown warning, even before she heard shots had been fired, she shouted at students: "'Get back in here! Get back in here!'"

Read: Suspected Florida school shooter remorseful and mournful, court hears

Victim's mom screams: 'Trump stop guns getting into children's hands'

Drawing from her friend's account five years ago of how she saved lives, Haneski quickly herded 50 students and five adults into a media equipment room in the rear of the library and locked the doors. The radio crackled with news that there was a gunman on the loose.

Some teachers thought it was simply a drill because school staff had just undergone "active shooter" training and were told a mock incident would take place, Haneski said. One teacher who climbed over the dead and wounded lying in the hallways assumed they were theatre students drenched in fake blood, she added.

But not Haneski.

"I felt right away this was real," she said.

She told everyone to sit the floor and hide behind something, equipment carts or large stacks of paper, and she covered a window and turned off the lights.

"I could see between the door and the floor. I could see if the bad guy - the shooter - walked past," she said. "At first it was just lockdown then right away we heard 'shooting'. We heard his name."

Nikolas Cruz, the accused 19-year-old gunman, was a student she had known since her previous job at the nearby middle school.

"He was a troubled child," she recalled.

Haneski, a mother of two sons aged 26 and 28, said the only way to stop such massacres was for Congress to tighten gun control laws.

"We did everything we were trained to do. And still this happened. And still 17 didn't go home after school," she said.