You can connect a Magic Keyboard to your Mac through Bluetooth or using the Lightning port and charging cable.
You can connect a wireless keyboard to a Mac or PC using Bluetooth, as long as the keyboard is charged and in pairing mode.