PDA

View Full Version : Key navigation, event for window on press Enter on keyboard



neosky
8 Dec 2014, 4:02 AM
Hello i am want make event on press key 'Enter' anywhere on the window 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 click 'enter' nothing happens.

lumberjack
10 Dec 2014, 9:06 AM
I've mocked up a fiddle to demo the KeyMap listener on a window.

Set focus to the window (click on it) then press the ENTER key. You should see an alert pop up.

Thanks,
Brian

es7