PDA

View Full Version : KeyMap - alert(key) !?



AntiSpeed
19 Sep 2010, 4:50 AM
hey@all
i like to alert the key who is pressed
my code (with commentars):


var map = new Ext.KeyMap(document, [
{
key: '0123456789',
fn: function(){alert('that was a number')}
},{
key: [96,97,98,99,100,101,102,103,104,105],
fn: function(){alert('that was a number')}
},{
key: 'abcde', //here all keys, the numbers on top are only from the example
fn: function(){alert('key')} //replace here 'key' into the key who is pressed
}
]);

Thank you for help

AntiSpeed
21 Sep 2010, 10:03 AM
Please help me. I can't find an answer...

Animal
21 Sep 2010, 10:21 AM
The docs are a bit poor. But if you look at the source, the key is passed as the first param. The keyboard event is the second.

troseberry
21 Sep 2010, 10:30 AM
You can for example on a textfield do the following


new Ext.form.TextField({,
......
enableKeyEvents: true,
listeners: {
keyup: function(thisField, evt) {
alert('Key Code = ' + evt.getCharCode());
}
},
.....
});
.....