Physical keyboard events on a chromebook

Hello. I added keyboard support to my game. It works beautifully when I compile the game for Linux (with “cocos compile . -p linux”), but does not work on any Android device. I tried Samsung Galaxy Tab S3 with an external keyboard connected through USB, and Acer Chromebook 11. Curiously, the “back” button works on both and registers as “Esc”.

The code I’m using:

auto keyboardListener = cc::EventListenerKeyboard::create();
  keyboardListener->onKeyPressed = [](cc::EventKeyboard::KeyCode keyCode,
                                  cc::Event* event) {
    // ...
  };
  keyboardListener->onKeyReleased = [](cc::EventKeyboard::KeyCode keyCode,
                                   cc::Event* event) {
    // ...
  };
  _eventDispatcher
  ->addEventListenerWithSceneGraphPriority(keyboardListener, this);

Since the Chromebook does not have a touch screen (which I think is common), that means the game is unplayable.

Some googling suggests that other also had trouble getting the keyboard to work on Android. Is there anything I can try to make it work? Is this even supposed to work?

I’m using cocos2d-x-3.17.2 for the Android build. Would things improve if I upgraded to cocos2d-x 4.0?

Thanks,

Aleksander

No. Upgrading to v4 doesn’t solve this. I was just talking to someone about this same issue. This should be something that gets fixed. I’ll ping the engineers to read this thread. Perhaps they may have some useful ideas.

I dont know how much chrome os is different from usual android, but on “normal” android, i believe, you can not detect alphabet keys, unless you write your own low level input driver. Without it, you can catch only F1-Fn, numeric, ctrl, alt, shift, space, esc and enter keys, but even this keys you can catch only after modifying one of cocos java classes (at least i did it and put my game into google play with this “partial” keyboard support)

Thank you for your responses.