There is a proximity sensor mounted on the display face. It is emitting infrared light and looking for a reflection back. It’s not very accurate but really does not need to be.
Even though its current draw is small I consider it a waste of battery power. The internal accelerators should be enough. Touch your phone and it wakes up.