To add a bit to what Jack said ...
No cable is necessary. Not sure who would have told you that it was.
Having WiFi and Bluetooth turned on, on both Macs, is necessary and sufficient.
Please Double-check that Handoff is allowed in Preferences -> General (at the bottom).
Also make sure that in Preferences -> Displays -> Universal control, that *all* three Universal Control items are checked.
Then, on the Mac that the keyboard & mouse is connected to, in Preferences -> Displays open the Add Display drop-down and you should see -- under "Link Keyboard and Mouse" -- the name of your other Mac.
You should be able to click on its name there to turn Universal Control on (and see a green check mark appear). Or, turn Universal Control on by using the mouse to drag the cursor over to and beyond one edge of the display of the Mac (the one with the keyboard & mouse) ... and the cursor should then appear on the display of the other Mac.