Ext JS - Problems getting a typical char?

Here is my problem ... Given this code ...

'keydown': function (textThis,e) { var cc = String.fromCharCode(e.keyCode); Ext.MessageBox.alert('Caracter',cc); } 

I always get type char I, but in uppercase ... Even if I type it in minus ... How can I solve this? Thankx to adavnce from Cordoba Argentina

+4
source share
1 answer

The keydown and keyup fire for each keypress (for example, for the shift key). They report the key (the "key" has no lower or upper case). keypress reports one event for combined strokes (e.g. SHIFT plus A) and ASCII code (with the correct upper / lower case representation).

The solution is to listen for the keypress event. If you support older browsers, you should go with this code (according to this site ):

 String.fromCharCode(evt.charCode || evt.keyCode); 

More on this stack question .

+6
source

All Articles