iPad Pro Keyboard Input

Hi there,

Anyone know if there is a way to map input from the iPad Pro external keyboard to into a Corona app?

I’d like to offer users the option of triggering certain events within the app with particular keys.

Thanks,

Ian

Have you tried this?  It should just work.

Typing on the external keyboard is the same as the virtual keyboard.  

I’ve tested this with my iPad and external keyboard.  It works.  This should be the same.

Oh, I see you maybe you want to not necessarily have a text field but to detect key presses for actions.

I think you can then just have a text field and move it off screen, or set isVisible to false.  

Then, set focus on the field and have your listener capture the key presses.

WASD here you come.

I don’t believe we support keyboard events on iOS. Of course it will work with native.*, but to trigger a “key” event, I don’t think we support that.

Rob

Ok thanks for the replies. We have built our own in-app keyboard to support a combination of special characters mixed with regular characters and also to allow more visual customisation of the keyboard, so I was looking to map the pressing of particular keys on the external keyboard to our keyboard. I’d also like to allow the pressing of arrow keys for example to move certain objects in the game itself.

I’m guessing as roaminggamer suggested, I can have a native textfield off screen and then capture the key presses and convert from there. Only problem I’ll have is some of the foreign characters but I’ll have a play when I can get hold of a keyboard and see where I get to. If I have any luck I’ll post back.

Thanks again!

Ian

You can go to our feature request site at http://feedback.coronalabs.com and file a feature request for this and get people to vote it up. Since keyboards will be more common with the iPad Pro and with enough community interest, we could consider adding that support. Before that though, we have to get 3D touch going.  Support for that rolled out in today’s daily build (2775). I don’t know if there is more work to do on it though. Then we have to add the pencil support. But getting this feature request created and voted up is the first step.

Rob

I’ve filed a feature request for this. I can confirm…

Using the native textfield works with the external iPad Pro keyboard, but it isn’t right for my purposes. We have custom characters and I want to be able to map other keys like Enter and Shift to do different things.

Using onKeyEvent doesn’t work with an external keyboard but it does work with my Mac keyboard in the simulator / Mac OS builds and also with Android hardware buttons like the Back key.

I’m slightly confused why the external keyboard doesn’t work in the same way as the Android hardware buttons and my Mac keyboard when it does work okay with the native textfield. If it’s working with native is it a difficult thing to get it working with onKeyEvent too?

Thanks,

Ian

native.newTextField() and native.newTextBox() are OS controls. They should work like any native app. If they do not, this is probably a bug.  Have you tried it with our two samples that use text fields?

Rob

iOS doesn’t support a “key” event equivalent.  Not even at the native level.  That is, you can get the characters generated by the keyboard, but not the pressed and released events of the individual keys/buttons from the keyboard.  This is a limitation on Apple’s end.  Because of this, it’s not possible to use a keyboard as a game controller like you can on Android, Windows, or OS X.  That’s just how Apple made it.

Ok thanks for the explanation Rob. Would love to see this feature added in the future.

As a way round it I’m doing what’s been suggested and trying the native textfield off screen, analysing the content and responding if a particular character is entered. I have a problem however…

Whatever I do, I can’t get the native textfield I’m adding to automatically take focus when the screen loads. I’m using the following code:

local tf = native.newTextField( 240, 50, 180, 30 ); native.setKeyboardFocus( tf );

I’ve also tried adding the line:

display.getCurrentStage():setFocus( tf );

But the textfield doesn’t take focus until I tap it. I want to be able to apply focus to it automatically so any input via a keyboard is added in there.

Any ideas?

Thanks in advance for your assistance with this.

Cheers.

Ignore that - it works fine on the device, just not in the simulator. Weird that it works when tapped in the simulator but not when focus is given to it programmatically. Is that how it should be?

Thanks.

Have you tried this?  It should just work.

Typing on the external keyboard is the same as the virtual keyboard.  

I’ve tested this with my iPad and external keyboard.  It works.  This should be the same.

Oh, I see you maybe you want to not necessarily have a text field but to detect key presses for actions.

I think you can then just have a text field and move it off screen, or set isVisible to false.  

Then, set focus on the field and have your listener capture the key presses.

WASD here you come.

I don’t believe we support keyboard events on iOS. Of course it will work with native.*, but to trigger a “key” event, I don’t think we support that.

Rob

Ok thanks for the replies. We have built our own in-app keyboard to support a combination of special characters mixed with regular characters and also to allow more visual customisation of the keyboard, so I was looking to map the pressing of particular keys on the external keyboard to our keyboard. I’d also like to allow the pressing of arrow keys for example to move certain objects in the game itself.

I’m guessing as roaminggamer suggested, I can have a native textfield off screen and then capture the key presses and convert from there. Only problem I’ll have is some of the foreign characters but I’ll have a play when I can get hold of a keyboard and see where I get to. If I have any luck I’ll post back.

Thanks again!

Ian

You can go to our feature request site at http://feedback.coronalabs.com and file a feature request for this and get people to vote it up. Since keyboards will be more common with the iPad Pro and with enough community interest, we could consider adding that support. Before that though, we have to get 3D touch going.  Support for that rolled out in today’s daily build (2775). I don’t know if there is more work to do on it though. Then we have to add the pencil support. But getting this feature request created and voted up is the first step.

Rob

I’ve filed a feature request for this. I can confirm…

Using the native textfield works with the external iPad Pro keyboard, but it isn’t right for my purposes. We have custom characters and I want to be able to map other keys like Enter and Shift to do different things.

Using onKeyEvent doesn’t work with an external keyboard but it does work with my Mac keyboard in the simulator / Mac OS builds and also with Android hardware buttons like the Back key.

I’m slightly confused why the external keyboard doesn’t work in the same way as the Android hardware buttons and my Mac keyboard when it does work okay with the native textfield. If it’s working with native is it a difficult thing to get it working with onKeyEvent too?

Thanks,

Ian

native.newTextField() and native.newTextBox() are OS controls. They should work like any native app. If they do not, this is probably a bug.  Have you tried it with our two samples that use text fields?

Rob

iOS doesn’t support a “key” event equivalent.  Not even at the native level.  That is, you can get the characters generated by the keyboard, but not the pressed and released events of the individual keys/buttons from the keyboard.  This is a limitation on Apple’s end.  Because of this, it’s not possible to use a keyboard as a game controller like you can on Android, Windows, or OS X.  That’s just how Apple made it.

Ok thanks for the explanation Rob. Would love to see this feature added in the future.

As a way round it I’m doing what’s been suggested and trying the native textfield off screen, analysing the content and responding if a particular character is entered. I have a problem however…

Whatever I do, I can’t get the native textfield I’m adding to automatically take focus when the screen loads. I’m using the following code:

local tf = native.newTextField( 240, 50, 180, 30 ); native.setKeyboardFocus( tf );

I’ve also tried adding the line:

display.getCurrentStage():setFocus( tf );

But the textfield doesn’t take focus until I tap it. I want to be able to apply focus to it automatically so any input via a keyboard is added in there.

Any ideas?

Thanks in advance for your assistance with this.

Cheers.