In this article, we'll walk you through how to connect a keyboard to your Mac computer. A wired keyboard can be connected to a USB port on a computer, and a wireless keyboard can be connected via Bluetooth. To connect a wireless keyboard, you need a mouse or trackpad.
Steps
Method 1 of 2: How to Connect a Wireless Keyboard

Step 1. Click the icon

It's on the left side of the menu bar at the top of the screen. A menu will open.

Step 2. Click System Preferences
This is the second option on the menu. The System Preferences window will open.

Step 3. Tap on the Bluetooth icon

It looks like a stylized blue "B".

Step 4. Click Turn on Bluetooth
Do this so that you can connect a wireless keyboard. If Bluetooth is already on, skip this step.

Step 5. Put the wireless keyboard into pairing mode
Your actions will depend on the keyboard model - to find out, read the instructions for the keyboard. When the computer detects the keyboard, it appears in the list of available Bluetooth devices.
To automatically connect your Magic Keyboard or Magic Mouse to Bluetooth, connect it to a USB port using the Lightning cable, and then turn on your device

Step 6. Click Connect next to the keyboard in the list of available Bluetooth devices
When the word “Connected” appears on the keyboard, the keyboard is paired with your computer and you can use it.
Method 2 of 2: How to connect a wired keyboard

Step 1. Connect the keyboard to the USB port
Do this with a USB cable or wireless USB dongle. USB ports are located on the back of most iMacs.

Step 2. Turn on the keyboard
If your device has a power button, press it. The computer will automatically recognize the keyboard.