Diana Haneski stands next to a cross erected for the victims of the school shooting in Parkland, Florida: REUTERS

A librarian saved the lives of 55 people when a gunman opened fire at a high school in Florida, killing 17.

Diana Haneski, a library media specialist at Marjory Stoneman Douglas High School in Parkland, jumped into action when she heard the school was under lockdown on her radio.

Before shots were even fired, she ushered 50 students and five adults into a media equipment room at the back of the library and locked the doors, shouting “Get back in here! Get back in here!”

Speaking to Reuters, Ms Haneski, 57, said she knew what to do as her friend, a fellow librarian, had managed to save 22 people during the Sandy Hook Elementary School massacre in 2012.

“She was there that day in Sandy Hook and because of her I knew what to do,” she said.

Her friend Yvonne Cech, a 58-year-old librarian, had previously locked 18 children and four adults into a small cupboard during the shooting.

Ms Haneski said some teachers at her school believed the shooting was a drill as they had recently undergone training and had been informed a simulated incident would take place.

Realising the shooting was real, she told people to sit on the floor in the media room and hide behind objects. 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, 19, has confessed to carrying out the attack on Valentine’s Day and has been charged with 17 counts of murder.

Ms Haneski, who knew Cruz from her previous school, was a “troubled child” and called for gun laws to be changed.

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

Related: