Yes, it is absolutely safe. The only issue you are likely to face is the fast battery draining. Since most wired physical keyboards don’t have their own battery, they will draw power from your phone’s battery. The OTG adapter you plug into your phone will also consume battery power, even if it is a wireless keyboard.