Github link: https://github.com/Dakkaron/Fairberry
Here's a video of it in action: https://www.youtube.com/watch?v=iDb8_ld9gOQ
I've been using it for almost two years now, and I'm not going back.
It's based on a spare Blackberry Q10 keyboard and a custom Arduino-compatible board that reads the keyboard matrix and outputs it as USB HID to the phone. From the viewpoint of the phone, it's just a regular USB keyboard, so no special software is needed.
But I do use a custom virtual keyboard to have just two rows of symbols that are not natively on the keyboard, as I didn't want to add another layer of rarely used symbols that I'd have to memorize.
(On the image you can see Ubuntu with XFCE4 running on it. I chose Ubuntu because it's what was easiest to get running in a chroot jail on the phone. I'm using VNC to display the GUI. I even managed to get FEX (x86/x64 emulator) and Wine running, so it runs x86/x64 Linux and Windows apps.)
Is it possible to do something like this that can be left on 100% of the time, with some sort of USB pass-through for further connectivity and charging? Or is that too asking too much of the board?
Pass-through charging would be possible, but I determined that if I put everything in that I want, the project would never be finished^^
I also considered adding a headphone jack, but that was also cut.
Passing through more than charging gets complicated fast. That would require a fitting hub. USB2 would be possible, USB3 would be difficult, stuff like display port would be really hard.
Also, afaik, a single USB port cannot be in host and device mode at the same time, so I believe it would be impossible to have the keyboard attached and connect the phone to a PC at the same time.
In the end I settled for a quickly detachable design to avoid all that added complexity.
Another option would be to use a phone with wireless charging and wireless connectivity.