How to process the Enter key with ExtJS
May 5th, 2011
To use the Enter key on your ExtJS forms, you need to setup a listener on your input fields.
For example:
{
xtype: 'textfield',
fieldLabel:'Password',
inputType:'password',
listeners:{
scope:this,
specialkey: function(f,e){
if(e.getKey()==e.ENTER){
Ext.Msg.alert('Keys','You pressed the Enter key');
}
}
}
}
So in the example above, there is a specialkey listener on the password field. If you press Enter while the password field has focus, the specialkey event will fire, your listener will get control and you can then handle the field and/or the form the same way clicking a button would.
Scott