Bluetooth keyboard pairing without code entry
This post explains how to connect a Bluetooth keyboard to your Linux/Mac/Windows computer without having to enter a pairing code. This is useful if you have a broken key on your keyboard, if you want to automate the pairing from a script, or you are building a custom keyboard that doesn’t have all the number keys connected (that’s me!).
Based on the Ubuntu Community Documentation for Bluetooth Setup, these commands were tested on Ubuntu Lucid Lynx 10.4, but should work on other version of Linux provided you can figure out how to install the necessary Bluetooth utilities.
First, we need to scan the available devices. Make sure your keyboard is in discoverable mode (push the button) before running the scan command.
matthew@broderick:~$ hcitool scan Scanning ... 00:12:A1:63:34:6E BluePacket Bluetooth Wireless Keyboard
This provides us with the device ID, similar to the MAC address of a network card. Copy this code to the clipboard for the next command. We need the hidd command, which is part of the bluez-compat package. On Ubuntu, you can install it with this command:
matthew@broderick:~$ sudo apt-get install bluez-compat
Next, we need to manually connect to the keyboard device ID:
matthew@broderick:~$ sudo hidd --connect 00:12:A1:63:34:6E
After this command finishes, your keyboard should be working with Linux. Try typing characters into vim or gedit, to make sure it’s working properly. Congratulations!
This solution was found at one of the Microsoft support forums. I know, I had no idea that Microsoft had support forums, either. Even more surprisingly, I was able to obtain useful information from a Microsoft webpage. To start, open up the Control Panel, and go to “Hardware and Sound”. Select “Add a Bluetooth device”:
When Windows is searching for your Bluetooth devices, put your keyboard into pairing mode (press the button). When it shows up in the list, don’t double click it! Instead, right-click on the keyboard device and select “Properties”:
In the window that opens, “Keyboard Properties”, wait a couple seconds for the services panel to load. Once it has loaded, check the box for “Drivers for keyboard, mice, etc. (HID)”. Click on “OK” to close the window.
Windows will load the drivers for your keyboard. After everything settles down, your keyboard should be working with Windows. Try typing characters into Notepad, to make sure it’s working properly. Congratulations!
Despite a couple hours of searching the web and trying all possible menu options, I was unable to figure out how to pair a bluetooth keyboard without having to type in a randomly-generated numeric passcode. If you know how to do get around this, please leave a comment below. Thanks!