Mark Revill
Mark Revill stalked Hollywood actress Keira Knightley. Police handout

A stalker, who targeted Pirates of the Caribbean star Keira Knightley with letters, postcards and threatening tweets while referring to himself as "public executioner", has been detained indefinitely.

Mark Revill sent a series of tweets to the Hollywood actress' husband, former Klaxons keyboard player James Righton, and even wrote letters to Knightley's mother.

The 50-year-old, who also goes by the name Ziggy, has been detained indefinitely at a psychiatric hospital after the Oscar-nominated actress was left fearing for her young daughter's safety.

Revill had admitted stalking Knightley in December 2016, but walked free from court after being handed an eight-week prison sentence suspended for 12 months.

He was also banned from contacting Knightley directly or indirectly, banned from going within 100 metres of her family and banned from going within 100 metres of any address she uses.

But, undeterred, the Hackney resident carried on trying to contact Knightley and has now admitted breaching a restraining order at Blackfriars Crown Court, the Daily Mail reported.

Under the alias Mark McCattipuss, Revill Tweeted: "My campaign of disobedience continues in Canonbury tonight. JR and KK are not going to get much help from the police."

He also wrote: "If Righton iz play the devil, maybe i iz play public executioner yah? Of course not iz death threat" and "Righton got too big for his boots last week. I iz cut him down to size yah?".

After delivering letters and postcards to her home he sent her a song called 'The Fuzzy Kitty Waltz', wrote two letters to her mother and made meowing noises through Knightley's letterbox.

Keira Knightley
Keira Knightley said she was left "shaken" by Revill's actions. REUTERS/Andrew Winning

Revill described his tweets as "like therapy," but Knightley said in a victim impact statement that the experience had left her "shaken" with her family now looking to move to move home.

She said: "This man has caused a lot of distress and panic. I'm scared every time I go outside. When I return home I have to look behind me concerned, I don't know who might be in shadows.

"If I was with my child we wouldn't have been able to run away easily. The thought of my daughter being at risk is my worst nightmare," she added.

During the hearing Revill admitted one count of producing 324 indecent photographs of children, one of distributing indecent photographs of children and one of sending menacing messages.

The defendant, a paranoid schizophrenic, had a previous conviction for indecent exposure and has been detained under the Mental Health Act.