Key loggers and the like are not illegal on a shared family computer, and the evidence you collected while she was living in the home should be admissible.
I suggest you subpoena your pediatrician to court to testify as to his opinion regarding the child being alone with your ex at the permanent custody hearing.
Your ex’s diagnosis can be considered in the custody case, but it is not the only factor to be considered and it not determinative on the issue of custody.