Turning Layers on/off via event

Hello all! New here!

I wanted to see if I can detect when a layer is turned off, and turn it on/off via event? Is this possible?