This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE hid Keyboard key press/release [Clarifications needed]

Hi,

We're working on a ble hid keyboard project, and we need some clarifications on how the keyboard keys press/release is done !

We've started with the example in the sdk v16.0.0, the example uses the keys_send() function to send a press followed by a release of that key. 

In this function there is  send_key_scan_press_release() , and i think this is the responsible for sending a press followed by a release of the key.

In our use case, we need to send just a press when the button is pushed, and a release when the button is released. in this case a hold on the button will output a successive key presses , and when released it will output just one release . this is achieved with the USB keyboard version using the app_usbd_hid_kbd_key_control() function.

 static void button_event_handler(uint8_t pin_no, uint8_t button_action)
    {
      ret_code_t err_code;
      switch(pin_no)
      {
       case BUTTON_1:
         if(button_action == APP_BUTTON_PUSH) {
            UNUSED_RETURN_VALUE(app_usbd_hid_kbd_key_control(&m_app_hid_kbd, CONFIG_KBD_KEY[0] , true));
            //NRF_LOG_INFO("button1 pressed");
         }
         else if(button_action == APP_BUTTON_RELEASE) {
            UNUSED_RETURN_VALUE(app_usbd_hid_kbd_key_control(&m_app_hid_kbd, CONFIG_KBD_KEY[0] , false));
            //NRF_LOG_INFO("button1 release");
         }
         break;
         
         }
    }     

the BLE  hid keyboard output on the host, should be as in the picture bellow (same as with the USB version) : 

USB hid keyboard log

Any help, clarifications, recommendations on how to achieve that is highly appreciated !

Best Regards,

Abdelali

Related