There are certain areas of the game which you enter via a door. An icon indicating that you must transition into this area will appear when you point over it.
Some door are always open, other are locked and can only be opened by a key, or by someone on the other side of the door.
When a door is opened the door will appear open, or the player is transported inside the building, in which case they can leave by the same method.
Some methods of entry are special and will be indicated with the same Door icon, but will differ in that they are a ladder or rope.
To open a door, use the 'E' (default key mapping) key, when the Door icon is showing.
To knock on a door, use the 'E' (default key mapping) key, when the Door icon is showing.
To attempt to open a door, use as stated before, however if it is locked, you will get a message pop up informing you of the reason and potential key to open. To open a locked door, which you have a key for, simply attempt to open it as state before.
Once a key is in your inventory it will stay there. Any door which is needed to open by this key will be permanently unlocked when you attempt to open it.