Hybrid View

  1. #1
    Sencha User
    Join Date
    Jul 2008
    Posts
    22
    Vote Rating
    1
    simplessus is on a distinguished road

      0  

    Default Get keycode on keypress, keydown or keyup in textfield

    Hello,

    i am trying to add a check for password-fields if caps-lock is active.

    Therefore I want to use my old function "check_capslock(e)". I don't know how to map that function to a textfield. I found various methods to do, but nothing works. I downloaded the newest version of ExtJs today.

    Here is my last try. I think "*" will not work, but I want to call that function if ANY character is pressed.

    Code:
            var map = new Ext.KeyMap(field_password.getId(), {
                key: "*",
                fn: function(e) { checkCapsLock(e); }
            });
    But even using "key: 'abcd'" does return me the keycode within the "e"-object.

    Best regards,
    Bjoern

  2. #2
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    83
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default

    why not just listen to the KEYUP event?

  3. #3
    Sencha User
    Join Date
    Jul 2008
    Posts
    22
    Vote Rating
    1
    simplessus is on a distinguished road

      0  

    Default

    How can I do this and receive the keycode ?

  4. #4
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    83
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default

    evt.getCharCode()

  5. #5
    Sencha User
    Join Date
    Jul 2008
    Posts
    22
    Vote Rating
    1
    simplessus is on a distinguished road

      1  

    Default

    I tried this, but firebug says "getCharCode" is not a function:

    Code:
            field_password.on('keyup',function(e,el) {
                alert(e.getCharCode());
            });

  6. #6
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    83
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      1  

    Default

    Look at the docs


    Event is the second param.

  7. #7
    Sencha User Alphawolf's Avatar
    Join Date
    Jul 2007
    Posts
    8
    Vote Rating
    0
    Alphawolf is on a distinguished road

      0  

    Default

    Thanks for the solution. Helped me lot.
    :|

  8. #8
    Sencha User
    Join Date
    Sep 2014
    Posts
    19
    Vote Rating
    -5
    MrFox can only hope to improve

      0  

    Default

    Keyup is slower when you want to edit the resulting text