Aston Robinson, 18, from Cheltenham, has admitted killing Kayleigh-Anne Palmer – who was six months pregnant – but denies murder.
He had been violent towards her in the past and did not like her talking to other boys, Bristol Crown Court was told.
Robinson also denies child destruction.
The court heard the pair had argued when Kayleigh-Anne had said ‘how would you like it if I saw some boys?’.
He used a mannequin’s head and piece of material the same length as the scarf he used to strangle his girlfriend to show the jury what happened on the day of the attack on April 2.
Robinson told jurors he punched her once in the arm and then demonstrated how he had grabbed the scarf at each end, looped it about her neck, and pulled her to the floor.
Asked if it was a deliberate act to stop her breathing, he said: “Yes, but not like that, only (for) a few seconds. I wanted her to be quiet.”
Talking about why he had strangled her, he said: “It will teach her a lesson… to stop her going with other boys.”
Robinson, who admitted having trust issues, said he put the scarf around her neck “to scare her” and had never intended to kill her.
Kayleigh-Anne was pronounced dead on April 5, after doctors induced labour.
The trial continues.