Actually the ipad magic keyboard and the Mac keyboard does works on the either Mac display that is currently where the cursor is on.
Unfortunately the magic keyboard trackpad cursor disappears on the ipad display you can use the 3 finger gestures only or only the Mac trackpad for either display but you must put the trackpad cursor on that display first. If you get Duet Display the Magic Trackpad partially works on the Mac apps on the iPad display.
on screen touch iPad gestures do work on the SideCar-Mac screen displayed on the iPad, the Apple Pencil also does work on that display as well.