This is a function called "Power On Alert". When you are connected to AC adapter, and the keyboard is powered on and left idle for about 6 minutes, the keyboard keys will light in a repeating pattern. This serves as a reminder that the power is still on.
You can disable Power On Alert to ensure that the keys do not light up (for instance, during a concert). You should check the manual for the procedure to disable Power On Alert (this procedure varies depending on the model). Some keyboards have the option labeled as "Demo 2" or "Demo2" in the menu.