Bluetooth keyboard

Fixing the “Alt Gr” key on a LogiLink wireless BT keyboard under Linux

Recently I found a cheap bluetooth keyboard from Logilink that I wanted to connect to my RasPi. The advantage of bluetooth on a Raspi is, that one can connect multiple BT devices without occupying an USB port.

After unboxing the keyboard I noticed that there is no “Alt Gr” key on the keyboard. Under Windows,  “Ctrl + Alt” can be used instead, but this didn’t work under Linux.

Unfortunately, there’s only a right “Ctrl” (Strg) key, but no “Alt Gr” on the keyboard.

Reprogramming the right Ctrl key under Linux

Due to the the lack of the “Alt Gr” I couldn’t enter chars like curly braces or the tilde sign, which is pretty bad for programming … However, here is the workaround: one can make the right “Ctrl” key behave like the “Alt Gr” key with the following commands:

xmodmap -e "keycode 105 = ISO_Level3_Shift Meta_R Alt_R Meta_R Alt_R"
xmodmap -e "remove control = ISO_Level3_Shift"

Pairing of the keyboard on a console

To pair the keyboard with the RasPi, check if the USB bluetooh dongle is recognized. This can be done with the command:

$ hcitool dev

It will return the hardware address of your dongle. You should see something like A1:B2:C3:D4:E5:F6. Next, scan for the address of the keyboard. Push the reset-knob on the backside of the keyboard, then:

$ hcitool scan

Again, you should see a hardware address with a format G1:H2:I3:J4:K5:L6. Now, you’ll be able to pair the keyboard using a pin, such as 1234:

$ bluetooth-agent --adapter hci0 1234 G1:H2:I3:J4:K5:L6

Confirm the pairing by entering the pin on the keyboard. You should see the message “agent released”. In order to use the keyboard, issue the command (“hidd” is part of the bluez-compat package):

$ hidd --connect G1:H2:I3:J4:K5:L6

Now you should be able to use the keyboard.