Recognising an external keyboard for gameplay

Hi there,

I was just wondering if anyone knew if it was possible in Corona to detect input from an external keyboard (bluetooth for example) in the same way my MacOS / Win32 builds do from the built in keyboard. Testing with my bluetooth keyboard the app doesn’t recognise the input in the same way.

I’ve had a number of people ask if we can add this feature to our apps but I can’t find any threads that give a definitive answer either way.

Thanks,

Ian

For iOS, a bluetooth keyboard doesn’t generate “key” events like a desktop or a game controller would. It’s only going to work with native.newTextField(), Box() and we can’t get those events. I’m less sure about Android, but I suspect it’s much the same.

Rob

Thanks Rob. So realistically we’ve got no way of grabbing key events directly from an external bluetooth keyboard in iOS… presume I could hide a native.newTextField() off screen and grab the input from that to then convert… bit of a hack but might do the trick… Will have a play and report back. Thanks.

Am trying to set the focus onto a native textfield so it can handle key input without having to actually tap on it.

Is there a way to do this without bringing up the on screen keyboard?

From the docs…

The native.setKeyboardFocus() API is used to show and hide the keyboard used for text input (applies to device and Xcode iOS Simulator only).

Thanks in advance.

Ian

I don’t think this will work. There are a couple of blue tooth plugins in the Marketplace (https://marketplace.coronalabs.com/search?search=bluetooth)

They might let you detect if a BT keyboard is paired and get events from them. But I suspect iOS is going to see the keyboard and want to use it natively.

Rob

Thanks Rob - appreciate the reply.

For iOS, a bluetooth keyboard doesn’t generate “key” events like a desktop or a game controller would. It’s only going to work with native.newTextField(), Box() and we can’t get those events. I’m less sure about Android, but I suspect it’s much the same.

Rob

Thanks Rob. So realistically we’ve got no way of grabbing key events directly from an external bluetooth keyboard in iOS… presume I could hide a native.newTextField() off screen and grab the input from that to then convert… bit of a hack but might do the trick… Will have a play and report back. Thanks.

Am trying to set the focus onto a native textfield so it can handle key input without having to actually tap on it.

Is there a way to do this without bringing up the on screen keyboard?

From the docs…

The native.setKeyboardFocus() API is used to show and hide the keyboard used for text input (applies to device and Xcode iOS Simulator only).

Thanks in advance.

Ian

I don’t think this will work. There are a couple of blue tooth plugins in the Marketplace (https://marketplace.coronalabs.com/search?search=bluetooth)

They might let you detect if a BT keyboard is paired and get events from them. But I suspect iOS is going to see the keyboard and want to use it natively.

Rob

Thanks Rob - appreciate the reply.