I have the same issue controlling my late 2015 27" iMac in my office with an older MacBook Pro at home. When I had the old Mac Pro tower (before the iMac), there was never an issue. Plus I always use wired keyboards and Logitech USB mice, which never caused any problem.
As soon as I got my MacPro (that could not update anymore) replaced with this crappy iMac at work the problems started. You can see in the Keyboard Viewer on the iMac that when I press any single key like command or option from my MBP, the Keyboard Viewer on the iMac shows all the modifier keys and FN key light up and stay that way. I have to hit random keys to get them unstuck temporarily, like for a second until you hit the next key. Trying to type in a text box in InDesign is nearly impossible. While the text tool is selected, it only wants to stretch the text box which skews it, like someone is holding keys down at the other end. I have disconnected everything (keyboard, mouse, bluetooth) from iMac and I have tried using different keyboard/mouse combination on this end making no difference whatsoever. This has to be something messed up with screen sharing no doubt as all keys and controls work fine for each computer locally.
Apple's geniuses have no clue after discussing it with them. They just want me to bring in the iMac to a center; but I can certainly reinstall everything myself—which is what they would probably recommend anyway. And more than likely since this iMac had a clean install, the issue would probably still be there after all that trouble.