Criminal Law Questions? Ask a Criminal Lawyer.
What state did this occur in?
The problem with what you have described is that by borrowing a key to an area you, yourself, could not get access to you were technically trespassing. It does not matter that this was your property - it was in an area you were not supposed to be in. However, I don't think this is something you wouldn't be able to clear up by explaining your story to the officer.
I will post the language of the statute below for your information.