How to use Mac Keyboard, on iPhone, with lightning cord?
I think the best solution would probably be to buy a lighting to USB adapter like this one as per this Lifewire article. The downside is that this sort of adaptor from apple usually carries a rather high cost with it. Therefore, I would recommend having a look around Amazon for a similar solution like this one but be sure to check out the reviews!

Hope that helped.

Kind regards, Tom