i had the same problem and I tried this and my keyboard was working.
1. Detatch ipad of out keyboard and turn off (no need to power off using the power button but you may try if this isn't working for you)
2. Now detach the keyboard off the magnetic contact and reattach
3. Turn on your ipad with wifi connection and place it down and attach to the magnetic contact to be in place.
See how it is working for you.
P.S. I read one of the solutions using the magnet moving on the magnetic field on the keyboard to activate the magnetic flux. It seemed working but then it was on and off. But after doing that I tried this and it always worked for me.