Here we will connect the Apple Magic Keyboard to the iPhone.

iPhone/iPad - Connect hardware keyboard via Bluetooth

Try using a Bluetooth keyboard

Disconnect Bluetooth keyboard