Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extjs listener on keystroke checking if its ANY character

I cant seem to find this anywhere. I want to find the best way to check whether a keystroke is actually a character.

listeners:{
    'keyup':function(f, e){
        //Is key a letter/character
    }
}

EDIT

Thanks to everyone who has answered, I DO know how to detect the actual key that was pressed, I want to know how to detect whether the key is actually a character (not arrows, backspace, enter etc)

like image 866
neolaser Avatar asked Dec 04 '22 08:12

neolaser


1 Answers

To capture keyboard events you must set the enableKeyEvents property on the component to true.

...,
enableKeyEvents: true,
listeners:{
    'keyup': function(f, e){
        var charCode = e.getCharCode();
        var key      = e.getKey();
    }
},
...

See "Detecting keystrokes" for a description of the difference between keyCode and charCode.

like image 150
Stefan Gehrig Avatar answered Apr 27 '23 16:04

Stefan Gehrig