If the keyboard used to work, go to the Bluetooth settings and forget it, then repair using the pairing instructions for the keyboard. Remember that the three way switch is meant to allow you to pair three different devices. Don’t use the same position that works for you iPhone (or other devices) to pair the iPad.
I used to have a Logitec keyboard with this feature (probably still do, somewhere); but I don’t remember the details on how to pair it.