Here are solutions for fixing the wireless connection between your Mac and the Magic Keyboard, Magic Trackpad, or Magic Mouse.
To establish a wired connection between your Mac and Magic accessories, you will need a Lightning cable.
If your Magic Keyboard, Trackpad, or Mouse are not connecting automatically to your iMac, Mac Studio, Mac mini, Mac Pro, or MacBook and you have waited for a while, just connect them with a Lightning cable.
In rare cases, your keyboard, trackpad, or mouse may stop working midway after losing connection or going out of battery.
Turn off your Magic Keyboard, Trackpad, or Mouse using the small power button and wait for at least 30 seconds.
Simply restart your Mac using the wired mouse and hopefully, the problem will go away.
Forget the Magic Keyboard, Trackpad, or Mouse from Mac’s Bluetooth settings and then reconnect it.
If your Mac is not running the latest version of macOS, go to System Settings > General > Software Update to download and install the newest version of the operating system.
If you still cannot connect your Magic Keyboard, Trackpad, or Mouse to your Mac, try these options: try restarting your Mac and forgetting and reconnecting your keyboard, trackpad.
Lastly, you can consider having your accessory inspected at an Apple Store.