PDA

View Full Version : [CLOSED] Textarea KeyMap ENTER + SHIFT not working



ontiv
Mar 05, 2013, 1:45 PM
Hi @all,

i tried the following example in my code :



var map = new Ext.util.KeyMap({
target: ta_comment.id,
binding: [{
key: Ext.EventObject.ENTER,
fn: function (e) {
alert('Enter pressed!');
}
}, {
key: Ext.EventObject.ENTER,
shift: true,
fn: function () {
alert('Shift+ENTER pressed!');
}
}]
});


If i pressed ENTER the event was fired but not Shift+ENTER !!

What is wrong ? Any idea ?

Thanks

Daniil
Mar 05, 2013, 2:19 PM
Hi @ontiv,

I think KeyMap doesn't support multiple handlers for a same key.

So, you could this binding like this.

Example

binding: [{
key: Ext.EventObject.ENTER,
fn: function (keyCode, e) {
if (e.shiftKey) {
alert('Shift+Enter pressed!');
} else {
alert('Enter pressed!');
}
}
}]

ontiv
Mar 05, 2013, 2:38 PM
Hi Daniil,

thanks this works for me!

Daniil
Mar 06, 2013, 7:32 AM
Another way is setting up "shift: false" explicitly to avoid a collision.

Example


binding: [{
key: Ext.EventObject.ENTER,
shift: false,
fn: function (e) {
alert('Enter pressed!');
}
}, {
key: Ext.EventObject.ENTER,
shift: true,
fn: function () {
alert('Shift+ENTER pressed!');
}
}]