EventListenerKeyboard doesn't work for Android?

cocos2d-x 3.17.1, Android Studio 3.3, C++, Bluetooth keybord + smartphone

In the Android environment EventListenerKeyboard does not seem to work,
which works fine in the Windows environment.

the code is as follows, “onKeyPressed” is never printed on Android.
How can I fix the problem ?

===
bool Hello::init() {

auto keyListener = EventListenerKeyboard::create();
keyListener->onKeyPressed = [this](EventKeyboard::KeyCode keyCode, Event* unused_event) {
this->m_label->setString(“onKeyPressed”);
};
_eventDispatcher->addEventListenerWithSceneGraphPriority(keyListener, this);

}

Are you saying Android as an operating system on the PC? If yes, what a good question. I didn’t test it. :thinking:

I tested both on Android OS and on Android emulater (blue stacks).
and it didn’t work in both environments.

Android OS on a PC or Android OS on a mobile device?

1 Like

I want to believe that it’s Android OS on a PC, because EventListenerKeyboard, as i know, is only used for desktop games. On mobile, always, Touch Events.

What if you have the on-screen keyboard up?

I don’t know, i never used EventListenerKeyboard on mobile. Is it also used in mobile? Because the documentation says “For desktop games”.

Yeah, that was written a long while back. We should adjust this chapter some, I think.

Let me explain the details.
I have released an Android application called “Tiny BASIC v2”, but I got a problem report that Bluetooth keyboard input isn’t accepted.
I did not have a Bluetooth keyboard so I bought it and tried it, but it certainly did not work. So I decided to ask a question here.

If my understanding is right, it seems that keyboard events are not supported in the mobile environment, but why is that?

Both,

I tested on the Android OS of ASUS smartphone and Bluestucks in Windows 10 environment, but I could not pick up key events in both environments.

oh, so you are using an emulator on Windows to test, now using an Android Desktop OS (like with a Pixelbook).

Keyboard should work, I would think. It would be easy to test. Perhaps I can find time to try it out. I have a bluetooth keyboard and a Vivo phone.