HID Keyboard: How to send a TAB character/keypress?

Posted on
  • With the below skeleton code I'm trying to send a TAB character (or should it be keypress?) instead of the letter A's. The intention is to control a program which is using the TAB-key to navigate forward, and SHIFT-TAB backward.

    If I intepreted the reference at https://www.espruino.com/modules/ble_hid­_keyboard.js correctly, "\t" might be TAB, but have not succeeded in replacing the ..KEY.A.. with ..KEY."\t".. or with some other variations.
    Can this be done, if so, how?

    var kb = require("ble_hid_keyboard");
    NRF.setServices(undefined, { hid : kb.report });
    function btnPressed() {
      // Send 'a'
      kb.tap(kb.KEY.A, 0, function() {
        // Followed by capital 'A'
        kb.tap(kb.KEY.A, kb.MODIFY.SHIFT);
    // trigger btnPressed whenever the button is pressed
    setWatch(btnPressed, BTN, {edge:"rising",repeat:true,debounce:50})­;
  • Ok, partially answering myself.
    Using the code from https://github.com/espruino/BangleApps/b­lob/master/apps/hidkbd/hid-keyboard.js and changing to 0x2b in next = function (cb) { sendHid(0x2b, cb); }; I'm able to simulate TAB by a gesture I've recorded.
    But how to simulate SHIFT+TAB?

  • Ok... found out how to use the first skeleton code, maybe it's of some help to others. So, just needed to add ["\t"], and then MODIFY.SHIFT as per below
    kb.tap(kb.KEY["\t"], kb.MODIFY.SHIFT);

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

HID Keyboard: How to send a TAB character/keypress?

Posted by Avatar for ThomasVikström @ThomasVikström