1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    8
    Vote Rating
    0
    giggle16 is on a distinguished road

      0  

    Default Unanswered: addKeyPressHandler in textfield does not work in chrome

    Unanswered: addKeyPressHandler in textfield does not work in chrome


    i have added an addKeyPressHandler in textfield,but it doest not work in chrome while in IE9 it works fine.
    is there any problem in my code like this:
    Code:
    usernameField.addKeyPressHandler(new KeyPressHandler() {            
         @Override
          public void onKeyPress(KeyPressEvent event) {
           if(event.getNativeEvent().getCharCode()+=KeyCodes.KEY_ENTER)
                    {
                        pwdField.focus();
                    }
                }
            });

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    It doesn't seem to be legal Java:
    Code:
           if(event.getNativeEvent().getCharCode()+=KeyCodes.KEY_ENTER)
    Assuming that is supposed to be '==' instead, you might be running into cross browser keydown vs keypress issues. Here's a post discussing this on SO: http://stackoverflow.com/questions/9...king-in-chrome

    From http://www.quirksmode.org/dom/events/keys.html it is suggested the IE is wrong here, not Chrome:
    Special keys

    When the user presses special keys such as the arrow keys, the browser should NOT fire keypress events.
    So try listening to keyup events instead.

Thread Participants: 1

Tags for this Thread