You can easily connect your headphones to a Mac from System Preferences, Control Center, or the Menu Bar.
You can connect a Magic Keyboard to your Mac through Bluetooth or using the Lightning port and charging cable.