title: `onChange` and `onKeyDown` in react
body: <pre><code>const Table = React.createClass({
  .............
  .............         
              handleChange: function(e) {
                  switch (e.target.name) {
                  case 'textarea':
                      if (this.state.newContent &amp;&amp; this.state.newContent.trim().split('\n').length &lt; 7) {
                          this.setState({newContent: e.target.value}); break;
                      } else {
                          break;
                      }
                  default:
                      console.error('Error in handleChange()'); break;
                  }
              },
  
              onKeyDown: function(e) {
                  if (e.keyCode === 8 || e.keyCode === 46) {
                      this.setState({newContent: e.target.value});
                  }
              },
  
  
  
      .....
      &lt;textarea type="text"
                          name="textarea"
                          value={this.state.newContent}
                          placeholder="Enter content here..."
                          onChange={this.handleChange}
                          onKeyDown={this.onKeyDown} /&gt;
      ......
      .......
  });
  </code></pre>
  
  <p>I'd like to have a textarea that would accept only 6 lines of input. When I enter 6 lines into the textarea and then press Backspace or Delete buttons, the <code>setState</code> does not get triggered, i.e. no character is deleted. How should i change the <code>handleChange</code> and <code>onKeyDown</code> functions so i could enter max 6 lines into the textarea and was able to remove characters from it too ? Thanks!</p>