Skip to content

Bluetooth Keyboard


On this page we will document what we have found about the bluetooth device that act like its a keyboard. The subjects that can be found here are .... If I have any recommendations, I will also let it know in the documentation.

Is there a library available to send bluetooth le keyboard commands?

I have found a library for the ESP32 that automaticaly setup and manages the bluetooth connection. When the device is connected via bluetooth then the device can act like it’s a keyboard. The device can now send key combinations to the phone. This will also make it possible to control Talkback / Voice over via the keyboard keys. By doing it this way you will control the os instead of only an app.

Here is the link to the library:

https://github.com/T-vK/ESP32-BLE-Keyboard

The library has also referenced to two other libraries that might be helpful when we want the device act like a gamepad or mouse.

Testing with a wired keyboard

I have tested to control talkback on my own phone by connecting a wired keyboard. A wired keyboard will act te same as a bluetooth keyboard, because the key combinations are the same. Also Talkback will react the same with a wired keyboard.

When testing talkback with the key combinations it worked as expected. This method could work to control your phone or app. The only thing is, is that you need to keep your phone unlocked and turned on. When your phone is locked, talkback will give information to unlock your phone. So it’s not possible to control the Stephear app with Talkback when your phone is on standby / locked. The phone needs to be awake and unlocked.

Testing how ESP32 can control iphone

Bluetooth keyboards are able to control your phone. To get more custom features, we are going to use an ESP32. This device has the possibility to connect via BLE and can handle multiple buttons and sensors.

Setup

This example uses ESP32 TTGO (Lora with i2c display included but not nessecary).

Add the library “ESP32-BLE-Keyboard.zip” at “Schets > Bibliotheek gebruiken > voeg .zip bibliottheek toe”.

Upload the Stephear_send_keystrokes.ino code to the ESP32 and connect your phone with bluetooth.

Open “Notes” and make sure the ESP32 can type words.

How to use ESP32 as keyboard without default keyboard dissepearing?

When the ESP32 is used as keyboard (so connected with the phone and keys are pressed), the phone’s keyboard dissapears. When the blind person wants to actualy type something, this can be very difficult.

Can you connect a bluetooth keyboard without letting the software-keyboard on your phone disappear.

No website did answer this question. The bluetooth keyboard takes over. The possible fix is turning the BLE keyboard off. Luckely is bluetooth fast so it can reconnect quite easily.

Does iphone-keyboard appear within 3 seconds after disconnecting remote?

After measuring 3 times, the keyboard appeared at an avarage of ~2.3 seconds. So we can conclude a user won’t have to acutaly wait for the keyboard to appear.

Can remote reconnect within 3 seconds?

When the remote is again, connected to a battery, it takes 2 seconds for it to reconnect.

Deepsleep solution

Deepsleep can shutdown the bluetooth functionalies and reduces battery use. The deepsleep code works just like shutting down the power, but as advantage it can remember the variables and boots up quicker.

The code that is written for enabeling deepsleep and turning deepsleep off, works as follows. Serial command ‘S’ (character) lets it sleep. The push of the hardware button turns it back on.

Conclusion keyboard-disappearance

There has to be a on/off button added on the ESP32, so you can use the onscreen-keyboard.


Last update: April 20, 2023