usually, it is better to take it out but leave it handy.
For example, if you have glass in the door, someone can break it and reach through to the key.
If you have a letterbox, a simple home-made tool can be used to turn the key (or the knob or handle of a nightlatch) through it
If you have a solid door with no glass and no letterbox, you can leave the key in if you want to.
Although, if you have a mortice lock, with your key in in, and for example you are taken ill or peg out, your trusted friend or neighbour will be unable to put his key in to open the door.
However...
If your house catches fire, you don't want your dead body to be found trapped against the locked door.
A good ruse is to put a hook near the door, for example at the top of the frame on the hinge side, where you can easily reach the key in such an emergency. Do not leave your keys on a hall table close to the door. It is very easy, and common, for people to reach through the letterbox with a hook on a rod and lift them away. This method is often used for taking car keys. Equally, someone standing at the door selling tea-towels or clothes pegs may grab the keys and run off with them.
This is why it is a good idea to have a key-safe where you keep all your keys that you are not actually using. Ideally, all keys should either be:
- In your hand, as you are locking or unlocking
- In your pocket of clothes you are wearing
or
- Locked in a keysafe, whose key is in your hand or pocket
There is a problem with great big bunches of keys, I have seen many offices where the manager leaves his great bunch of keys in the keyhole of the safe. This is of course stupid, since anyone who gets inside the building then has no trouble opening it. That's why I carry a bunch with just three keys: My front door, my car, and my keysafe.