Skip to main content
Inspiring
May 1, 2013
Question

"Enter" button keyCode change in AIR3.7

  • May 1, 2013
  • 3 replies
  • 1074 views

Not sure if this is a bug or a simple feature change?

I noticed that the soft keyboard 'Enter' key returns keyCode '10' instead of  the traditional '13' in AIR3.7 on Android (tested on a Nexus 4 & 7).

It means the hardcoded actionscript 'Keyboard.ENTER' no longer works for that button. For example, this won't catch the 'Enter' key:

_nameInput.addEventListener(KeyboardEvent.KEY_UP, keyUp);

private function keyUp(event:KeyboardEvent):void

{

          // test for '13'

          if (event.keyCode == Keyboard.ENTER)

          {

               //  submitting form here etc

          }

}

Instead, the Enter key will add a linebreak to the textfield.

My workaround is to detect both keycodes:

if (event.keyCode == Keyboard.ENTER || event.keyCode == 10)

This topic has been closed for replies.

3 replies

Adobe Employee
May 3, 2013

Hi,

Could you please confirm the Enter key you are talking about. Is this the same as marked in red on the softkeyboard in the attached image.

Regards,

Nimit

banzai76_Author
Inspiring
May 3, 2013

Yes, that's the button I was talking about. Although I can see you're getting keyCode 13 when you try it. Here's what I see:

1. I bring up a login screen with 2 input textfields on (not stagetext, just normal single line input textfields). Then I tap on the username.

2.  I get this alternative layout alongside the soft keyboard (maybe because my app is in landscape?). I enter username and tap the key marked in red.

3. The debug console traces this when I tap the key marked in red:

Key Event: [KeyboardEvent type="keyUp" bubbles=true cancelable=false eventPhase=2 charCode=10 keyCode=10 keyLocation=0 ctrlKey=false altKey=false shiftKey=false controlKey=false commandKey=false]

Incidentally, the 'Done' key does not trigger the keyboard event (but this is correct behaviour IMO, as it's not part of the keyboard). It might be nice to be able to capture it somehow though.

Adobe Employee
May 3, 2013

Would it be possible for you to share a sample project at nimitja@adobedotcom so that we may try reproduce this locally?

-Nimit