LordZardeck
LordZardeck

Reputation: 8283

extjs keymap on Ext.form.field.Text

I'm trying to capture when the user presses the enter key in the textfield. I've tried using the listeners config parameter, and I've tried the KeyMap class. I can't get either to work. Here's my code for the keymap:

var bcTextField = Ext.create('Ext.form.Text', {
    xtype: 'textfield',
    emptyText: 'Enter Barcode/Accession Number',
    width: 200,
    margin: '0'
});
var map = new Ext.util.KeyMap({
    target: bcTextField,
    binding: [{
        key: 13,
        fn: function() {
            console.log(arguments);
        }
    }]
});

Does anyone have any idea what I could be doing wrong?

Upvotes: 0

Views: 1596

Answers (1)

sha
sha

Reputation: 17860

Usually KeyMap binds to the HTML element not the ExtJs object. So I would recommend first replace target: bcTextField with target: bcTextField.getEl()

Upvotes: 2

Related Questions