It is unlikely that your friend's having a key is, of itself, enough to defeat a trespassing charge, as the two of you were ordered to leave. You had permission to come in, sure, but the permission was revoked.
Your defense to the trespassing charge apparently is that you were attacked by the homeowner, and were in too much fear to leave the bathroom, let alone her house. The prosecutor apparently doesn't believe you. The police report may shed some light on what the police and prosecution believe happened.
If you can't afford a lawyer and are charged with a criminal trespass, you should be able to apply for a court appointed lawyer to assist you with your defense.

