A jealous man stabbed his ex-girlfriend and her new partner to death outside the shop where they worked after researching how long murderers spend in prison and the easiest ways of killing, a court has heard.

Andrew Saunders, 21, has pleaded guilty to murdering Zoe Morgan, 21, and Lee Simmons, 33, outside the Matalan store in central Cardiff.

At the start of his sentencing hearing on Monday, Philip Bennetts QC, prosecuting, said Saunders and Morgan had been in a two-year relationship but he was controlling and violent.

Morgan broke up with him last July and began dating her colleague Simmons.

Bennetts said Morgan and Simmons were waiting outside the store on Queen Street shortly before 6am on 28 September when Saunders appeared.

He stabbed Simmons, who worked in the warehouse, with an 8ins (20cm) knife. “Zoe Morgan tried to pull the defendant off Mr Simmons,” Bennetts said. Saunders told her to get off before warning her: “I’m coming for you next.”

Morgan ran away after Simmons collapsed, but Saunders caught up with her. He took a second knife, measuring 10ins (25cm), from his rucksack and stabbed her. Both victims had eight stab wounds.

Bennetts said that during their relationship Saunders was controlling towards Morgan, a window dresser, and she once told her father that he had grabbed her neck during a row.

When Morgan told Saunders their relationship was over, he accused her of cheating on him, adding: “I will kill whoever it is.” She began dating Simmons in July 2016.

The court heard that when he found out, Saunders contacted Simmons on Facebook, telling him that he would kill him. He sent abusive messages to his former girlfriend and also told her: “I love you still as I just do.”

Floral tributes outside the Matalan store in Queen Street, Cardiff. Photograph: Benjamin Wright/PA

Bennetts said in the weeks leading to the murders, Saunders searched online for “the easiest way to kill a person”, “how many years for killing a person”, “16 steps to kill someone and not get caught” and “how long do murderers serve in prison”.

On 21 September, Saunders searched “Is it as easy to slice someone’s throat as they make it look in movies and TV shows”. He also looked up “how to blow up a car without being caught” and “how can a car be rigged to explode when started”.

He researched how to make pipe bombs, the court heard, and purchased an air rifle and 500 pellets. Saunders also bought two knives and latex gloves from a supermarket. These were used in the attack.

Before he left for Cardiff, Saunders left a letter at home, suggesting he intended to take his own life. “You know you are messed up when you think like I do,” he wrote. “Thinking of shooting up Cardiff every day for months and years is pretty dark. I think Isis is the good guys most of the time and that is just messed up. No one will forget me.”

After the killings he texted his father: “Thanks for being a pathetic, useless father. Just killed two people. Cheers.”

Cardiff crown court heard Saunders had not been diagnosed with any mental health problems but was experiencing “significant emotional distress” at the time of the incident.

In a victim impact statement, Morgan’s mother, Julie, said: “I think about her constantly and how she must have suffered. She was a beautiful, bright and hardworking girl.”

Simmons’s father, Alfred, said: “Lee found love in Zoe and I’m so happy for that. I can’t look at the photographs I have of Lee as a child, it hurts too much.”

Saunders, of Newport in south Wales, is due to be sentenced on Tuesday.