Jordi Jordi - 11 months ago 90
HTML Question

ReactJS handle tab character in textarea

How can I handle tab key pressed events in ReactJS so I'm able to indent text inside a textarea?

onChange event does not get fired when tab is pressed on the textarea, so I guess there might be a higher level handler I can use to detect this event.

Answer Source

you can try onKeyDown and get the keycode for tab.

add: function(event){
    console.log(event.keyCode); //press TAB and get the keyCode
render: function(){
            <input type="text" id="one" onKeyDown={this.add} />