Hi dubheadgem,
Thank you for reaching out to Apple Support Communities.
From your post, it looks like you have an issue with the keyboard disconnecting when connecting to Bluetooth. We want to help. Does this issue only happen when using your AirPods with your iPhone?
If you have not yet done so, update your iPhone. It is a good practice to back up your iPhone before updating.
Here’s How to back up your iPhone, iPad, and iPod touch - Apple Support
Here’s how to: Update your iPhone, iPad, or iPod touch - Apple Support
If the issue remains, we would recommend restarting your device. Here’s how to Restart your iPhone - Apple Support
If this issue is only happening with your AirPods, you can Reset your AirPods - Apple Support and test again.
Hope that helps.
Best Wishes!