How to share a Bluetooth keyboard and mouse between two Macs

How to share two Macs to control two or more computers with one set of mouse and keyboard in a software way without external hardware devices, provided that the two computers are on the same LAN.

Two apple computers

How to set up two Mac computers to share a mouse and keyboard
Requirements for Universal Control
Mac computers need to be running macOS 12.3
Both devices need to be logged into the same iCloud account and both be double-authenticated.
Both devices need to be within 10 meters of each other and on the same WiFi network.
How to share a mouse and keyboard
Open System Preferences on one Mac computer.
Then in Preferences, click on "Monitors".
Go to the monitor screen and click on "General Controls".
In the General Controls settings panel, check the boxes "Allow your cursor and keyboard to move between any nearby Macs or iPads," "Push over the edge of the display to connect to a nearby Mac or iPad," and "Automatically reconnect to any nearby Mac or iPad. any nearby Mac or iPad".
Do the same on the other Mac computer.
Then click on the blue triangle icon to the right of Add Display and select the name of the Mac in the drop-down menu.
Finally, we move the mouse from the first computer to the second computer and open the file to try to type. Bluetooth keyboard and mouse