Defold app won't accept keyboard input on android device via USB-OTG (SOLVED)


I am going to try building a HTML5 and getting that running on Chrome on the android device. Is that likely to help?


Have you bound a text action in your input bindings? I got some key presses from the numpad that way.


I don’t know what that means
edit: Okay, I see what that means and will investigate that.

But i expect that the input from the makey makey (basically a generic gamepad with the letters W A S D F and G, a space bar, a 4 way d-pad, and a right click) won’t work? Or, at least, the D-Pad won’t work. right click already works and the letters and space bar can probably work as text input


Yes, this:

I guess this should work for basic key input like 0-9 on the numpad. BUT we should also support Android key events to Key Triggers.

Yes, this is likely true. We need to wait for the Android key event to Key Triggers to get that to work.

Since you’re in a rush I wonder if you could move faster with a native extension that forwards key events to Lua?


Takk for all your help (takk? is that right?!) Britzl! I really appreciate it.

At the moment I am going to investigate the possibility of adapting my hardware. I know it’s possible to hack the makey makey ( this just in case anyone has read this far without knowing what it is ) so I could probably change the D pad to assign it to some other key presses.

If that doesn’t work, I am going to try and run the game in HTML5 on Chrome on Android OS to see if key inputs are passed correctly that way.

If anyone has any idea how a native extension might be built for this task (letting defold correctly interpret key presses from a keyboard connected to an android device via USB-OTG) I would be interested in hearing about it!

If none of the above work I am going to set fire to all of my personal possessions and go and live in the woods.

Do not open this suitcase: devlog

Almost, it’s tack!

We wouldn’t want this to happen.


Okay, next question.

I have done this

and this

But I am not printing anything when I press the key assigned to a text input (on my mac!)

edit: Sorted it now. I cannot even begin to describe how accurate this meme is:


You should only have one text trigger. When keyboard input is detected it will end up in the action_id you assigned to the text trigger and the key pressed in action.text


Okay! Just a quick update for those still paying attention:

the text trigger method did work and I was able to get the keypad working with the android app to some extent…

…but not to the extent that is necessary for my game. text triggers don’t have action.released, action.pressed, or action.repeated. And those are vital for me, because each “cable” in my “bomb” is a completed circuit attached to the makey makey. The computer interprets this as a key being held down. Just like in those old Bond films, you have to disconnect the cables in the correct order (=the computer must receive the action.released in the correct order) in order to avoid the explosion sound effect that signals your doom. I am going to continue experimenting, this time focusing getting a HTML bundle and playing it in the chrome browser on the android device.

Wish me luck!


Quick question:

Are android key events like to be included in defold in the near future? and, how near is that future?


I’m afraid it’s probably not soon enough for you. We’re releasing 1.2.123 soon and that means it’s two weeks until next release.

I could take a look at the code tomorrow and get started on the work but I can’t make any promises.


HTML5 apps created in defold accept android key events when played in the browser of an android device!


there’s just no sound and everything is very slow.

Okay next question: what tool exists on the internet that can convert an HTML5 file into an android APK?


Just to update this thread as well so there are no doubts: Apps built in defold now correctly interpret key presses from USB OTG devices, at least in the alpha build that Britzl has sent to me. I expect these changes will be included in the main build soon. So i’m joyfully marking this as solved.


Excellent! I’m happy that the solution worked out well for you. The Android key trigger support will show up in Defold 1.2.124