A man peeped at the Messenger of Allah ﷺ through a hole in the Prophet's ﷺ room while the Prophet ﷺ held a comb with which he was scratching his head. The Prophet ﷺ said, "Had I known you were looking, I would have stabbed it into your eye. The requirement of seeking permission was established only because of sight."
حدثنا ابن أبي عمر حدثنا سفيان عن الزهري
أن رجلا اطلع على رسول الله ﷺ من جحر في حجرة النبي ﷺ ومع النبي ﷺ مدراة يحك بها رأسه فقال النبي ﷺ لو علمت أنك تنظر لطعنت بها في عينك إنما جعل الاستئذان من أجل البصر
Agreed upon. Muslim narrated it in the Book of Manners, chapter on the prohibition of looking into someone else's house, no. 2156, from Muhammad bin Abu Umar, and Bukhari, no. 6241, from the hadith of Sufyan bin Uyayna, through this same chain.There is also a narration on this subject from Abu Hurairah [Bukhari, no. 6902, and Muslim, no. 2158].