Charge the batteries in your accessories
Your Magic Keyboard and Magic Mouse 2 each have a built-in rechargeable battery.
Charge the battery. Connect your Magic Keyboard or Magic Mouse 2 to your iMac with the included Lightning to USB cable. To check the charge level, click in the menu bar at the top of the screen, then choose the device.
Tip: To charge the battery faster, be sure your input device is turned on when you connect it to your iMac.