Results 1 to 3 of 3

Thread: How to Send a Keyboard Event to a Component?

  1. #1
    Sencha Premium Member
    Join Date
    Aug 2007
    Location
    NYC
    Posts
    93
    Vote Rating
    0
      0  

    Default How to Send a Keyboard Event to a Component?

    How do I send a keyboard event to a component? I want to simulate an enter keypress on a text field. I have the following code:

    Code:
            ST.textField('mypanel textfield[reference="myField"]')
            .type('something')
            .execute(function(cmp){
                 //cmp.fireEvent(new KeyboardEvent('keydown', { keyCode: 13 }));
                 //here?
            });

  2. #2
    Sencha User
    Join Date
    Mar 2016
    Posts
    59
    Answers
    6
    Vote Rating
    1
      0  

    Default

    You can use an undocumented property of the type() method, "key".

    For a test I used this Ext example in Kitchen Sink: http://examples.sencha.com/extjs/6.5...orm-fieldtypes

    Code:
    describe("test", function() {
        it('should type a special key', function () {
            var tf = ST.textField('textfield[name="textarea1"]');
            tf.type('foo');
            tf.type({key: 'Enter'});
            tf.type('bar');
        })
    });
    Key strings documented here should generally work though probably will depend on your browser somewhat of course.

    https://developer.mozilla.org/en-US/...key/Key_Values

  3. #3
    Sencha Premium Member
    Join Date
    Nov 2013
    Posts
    11
    Vote Rating
    0
      0  

    Default

    The remaining question for me is: why is this not documented?

Similar Threads

  1. date component - selection with keyboard not possible
    By karenina in forum Sencha GXT Bugs
    Replies: 2
    Last Post: 17 Sep 2013, 6:04 AM
  2. [CLOSED] Can see datePicker component, it's covered by soft keyboard.
    By aaronchen2k in forum Sencha Touch 2.x: Bugs
    Replies: 3
    Last Post: 24 Oct 2012, 5:51 AM
  3. What is the keyboard shortcut for Component Config Focus?
    By ottobar in forum Sencha Architect 2.x: Help & Discussions
    Replies: 2
    Last Post: 21 Mar 2012, 10:50 AM
  4. Replies: 2
    Last Post: 10 Jan 2012, 7:23 AM
  5. Where is the event handler for Ctrl + Z keyboard event in the textfield?
    By duc-cuong in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 23 Nov 2009, 10:01 AM

Posting Permissions

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