Ryan Whiteman, 24, was found hanged at Newton Lodge at Fieldhead Hospital in Wakefield last March, Wakefield Coroner's Court heard.
The inquest jury was told long-term drug user Mr Whiteman, of South Elmsall near Pontefract, was charged with sexually assaulting a woman on a bus when he appeared at Leeds Crown Court in October 2014.
Mr Whiteman, who previously worked as a bricklayer, was on remand in prison where his behaviour led to him being admitted to Fieldhead Hospital under the Mental Health Act on November 27 2014.
On March 12 2015 at Leeds Crown Court he was found guilty of the sex assault and admitted to Fieldhead Hospital under the Mental Health Act.
The inquest heard Mr Whiteman, who had been diagnosed with paranoid schizophrenia, had been under 30-minute observations at the time of his death.
Mr Whiteman was found with a ligature around his neck at around 1.30am on March 22 2017.
The inquest jury heard staff and paramedics attempted to revive him and he was taken to Pinderfields Hospital, where his death was confirmed just after 3am that morning.
Consultant pathologist Dr Paul Bennett carried out a post mortem and gave the cause of death as hanging.
Assistant Coroner Jonathan Leach said Mr Whiteman was expelled from school aged 13 after being caught in possession of cannabis.
The inquest was told his drug use continued and became involved in crime, had mental health issues and was admitted to psychiatric hospitals on seven occasions between May 2011 and August 2014.
Reading a statement from Mr Whiteman's mother Dawn Hazelhurst, Mr Leach said as well as cannabis, he also took amphetamine and abused aerosol sprays.
Dawn Hazlehurst said in the statement that he continued to get access to the drug Spice while he was being treated at Newton Lodge.
The inquest was told that on March 3 2017 Mr Whiteman had told staff at Newton Lodge that he was depressed and wanted to kill himself.
Mr Leach read a statement from Forensic pathologist Dr Kiara Bird, of South West Yorkshire Partnership NHS Foundation Trust.
Dr Bird wrote in the statement Mr Whiteman had told her he had started to smoke cannabis when he was eight-years-old.
The jury inquest continues.