user3045654
user3045654

Reputation: 1734

Key navigation, event on press Enter on keyboard

Hello i am want make event on press key Enter on keyboard. I am do this:

 listeners: {
    afterRender: function (thisForm, options) {
        this.keyMap = Ext.create(
            'Ext.util.KeyMap',
            this.el,
            [
                {
                    key: 13,
                    fn: this.submitOnEnter,
                    scope: this
                }
            ]
        );
    }
},

submitOnEnter: function (e) {
    if (e === 13) {
        console.log('some event there!!!')
    }

},

but when i press Enter nothing happens.

Upvotes: 1

Views: 2455

Answers (1)

Michael Watson
Michael Watson

Reputation: 318

If it's a textfield or combobox or trigger or something you can try adding a listener for specialkey:

        listeners:{  
            specialkey: function(f,e){  
                if(e.getKey()==e.ENTER){  
                    console.log("I hit enter!"); 
                }  
            }  
        }, 

If it's just hitting Enter anywhere on the window then I'm not as sure. Something similar might work.

Upvotes: 2

Related Questions