It is narrated from Hazrat Sahl (may Allah be pleased with him) that once a man began to peep through a hole into the blessed chamber of the Holy Prophet (peace and blessings be upon him). At that time, the Holy Prophet (peace and blessings be upon him) had a comb in his blessed hand, with which he was combing his hair. The Holy Prophet (peace and blessings be upon him) said, "If I had been sure that you were looking, I would have struck your eyes with this comb. The command for seeking permission has only been given because of the gaze."
Hadith Referenceمسند احمد / مسند الأنصار رضي الله عنهم / 22802