How would I use this to check if the player has a key and is touching a door?

Not sure how to use this.

Thanks

This example can be implemented very simply.

Add OnControllerColliderHit(ControllerColliderHit hit){} to your code and it will be called whenever something collides with the script.
Add this to your door and and the tag “Key” to your lock.
Then you can go

OnControllerColliderHit(ControllerColliderHit hit){
 if( gameObject.tag == "Key") {
   //Code for door hit here
    return;
 }
 else {
   return;
 }
}