Probably not the cheapest nor the easiest way, but take a look at Cynthion: https://greatscottgadgets.com/cynthion/
On the hardware side, it probably has what you need (and more).
(I would use it to use a laptop keyboard on a headless computers).
I am looking for an easy solution, it does not have to be the cheapest.
ChatGPT points me to Arduino, but as far as I can see, there's no arduino with 2 usb ports. It also points me to Raspery pi zero, but that's a computer, not a microcontroller, so not sure if it's suitable.
If anyone with experience can give me some pointers, it would be greatly appreciated!
On the hardware side, it probably has what you need (and more).