First, ensure that your device is not in "Low Power Mode".
Please read this article to make sure you are using the correct connection path.
Additionally, you must verify that you are connecting your keyboard with an authentic Apple adapter. Third party adapters will not work. There are 2 kinds of Apple adapters that will work.
- Lightning to USB Camera Adapter (for iPads with Lightning ports)
- USB-C to USB Adapter (for iPads with USB-C ports)
Please read this article for more common troubleshooting solutions.