Results 1 to 2 of 2

Thread: addKeyPressHandler in textfield does not work in chrome

  1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    8
    Vote Rating
    0
      0  

    Default 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,737
    Answers
    109
    Vote Rating
    93
      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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •