The "key" event never fires. Why?

This is the code in my main.lua.

-- Called when a key event has been received. local function onKeyEvent( event ) print(555) return false end -- Add the key event listener. Runtime:addEventListener( "key", onKeyEvent ) print(123)

The console output shows “123”, but no matter what buttons I press in the windows simulator, it never shows “555”.

Why does this event never fire?

Hi,

When I run your code it works fine for me in the simulator.

Can you try again and if it still doesn’t work check if there is some other code (like to functions with the same name or something) that might cause this problem?

Best regards,

Tomas

Everything works 100% when simulating a Droid machine, but iPhone, iPad etc. just nothing. Is the keyboard event simply disabled for all but Droid simulation?

Ahh, ok.

http://docs.coronalabs.com/api/event/key/index.html

Maybe this explains things:

iOS

Does not support key events.

Windows

The Corona Simulator for Windows only supports key events when simulating an Android device. Currently, Windows only supports keyboard keys and not gamepad/joystick buttons.

Best regards,

Tomas

Oh, I’m sorry. Not sure how I managed to miss that information. I remember reading through it. My bad.

Thank you for help, bro!

It’s by design since iOS devices do not support “key” events.

EDIT:

Ooops, sorry. Already answered. That’s what I get for not scrolling down to read more… :wacko:

:smiley: It’s fine, man, you’re only trying to help. Thank you!

Hi,

When I run your code it works fine for me in the simulator.

Can you try again and if it still doesn’t work check if there is some other code (like to functions with the same name or something) that might cause this problem?

Best regards,

Tomas

Everything works 100% when simulating a Droid machine, but iPhone, iPad etc. just nothing. Is the keyboard event simply disabled for all but Droid simulation?

Ahh, ok.

http://docs.coronalabs.com/api/event/key/index.html

Maybe this explains things:

iOS

Does not support key events.

Windows

The Corona Simulator for Windows only supports key events when simulating an Android device. Currently, Windows only supports keyboard keys and not gamepad/joystick buttons.

Best regards,

Tomas

Oh, I’m sorry. Not sure how I managed to miss that information. I remember reading through it. My bad.

Thank you for help, bro!

It’s by design since iOS devices do not support “key” events.

EDIT:

Ooops, sorry. Already answered. That’s what I get for not scrolling down to read more… :wacko:

:smiley: It’s fine, man, you’re only trying to help. Thank you!