MacBook Air screen turns off randomly

I had my MacBook Air 13" 2011 for almost 2 years now. And right from the start I kept having this weird issue: sometimes while I'm working on it, the screen (and the monitor attached via displayport aswell) randomly shuts off (or goes to sleep). The computer is still active and everything is still running normally, so If I hit a key it goes back on normally... It happens even if my power cord is plugged in. It's not a big deal, but it sometimes gets very annoying when it happens while I am typing.
Any clues?
Thanks!


Solution 1:

Assuming it only happens sometimes and only when you are actively using the computer (key board & Mouse)

Lets find out if it is you doing it.

Check your settings for Display Sleep in:

System preferences> Desktop and Screen saver> Hot Corners!

In here look if you have a setting to put display to sleep.

Solution 2:

Mine did the same. Apple fixed it four times and even replaced the computer without resolution of the problem. I finally discovered that it was the magnetic clasp on my Apple Watch band triggering the magnetic sensor in the upper left portion by the keyboard. This is normally triggered by a magnet in the lower left portion of the display that the tells the computer when it is shut.