Solution to detect key present in door lock?
Depending on the type of your door and key, you might have some success with inductive measurement from the inside. If your door, lock, and cylinder are mostly diamagnetic, and the key is ferromagnetic , you can measure a change in inductance of an inductor mounted on the inside of the lock when a ferromagnetic key is inserted. This should work for paramagnetic keys as well. 

If your key is ferromagnetic, you might successfully magnetise the key and measure the inducted electromagnetic field when the key is inserted. 

If the door cylinder is useable from both sides, you might insert a pin into the lock from the inside that will be moved when a key is inserted on the outside. Not a good idea because it might possibly damage your lock, though.

A totally different way would be to force people to put their keys on a specific hook, and alert if the key is not there. 

Or make the door keyless.