I used to use Synergy for this until switching to Wayland, which isn't supported. Last time I checked there was a project called RKVM attempting to do the same thing for Wayland but it was very buggy at the time. I should check again to see if there has been any progress.