title: jQuery: selectionStart returns undefined
body: <h1>Situation</h1>
  
  <p><strong>browser</strong></p>
  
  <p>Google Chtome 69</p>
  
  <p><strong>html</strong></p>
  
  <pre><code>&lt;textarea id="message" name="message"&gt;
      // input some messsage
  &lt;/textarea&gt;
  </code></pre>
  
  <p><strong>js(jQuery)</strong></p>
  
  <pre><code>$(function () {
    $("#message").on("keydown keyup keypress change", function () {
        //this part runs correctly
    })
  
    $('#message').on('keydown', function (e) {
      if ((e.wich &amp;&amp; e.wich === 13) || (e.keyCode &amp;&amp; e.keyCode === 13)) {
        var $textarea = $(this);
        var sentence = $textarea.val();
        var position = $textarea.selectionStart;
        var length = sentence.length;
        var before = sentence.substr(0, position);
        var after  = sentence.substr(position, length);
        sentence = before + "\n" + after;
      }
    });
  });
  </code></pre>
  
  <p>When I input something in the #message textarea and push Enter key in the area, nothing would happen. According to Chrome developer tool, selectionStart method seems to return <code>Undefined</code>.</p>
  
  <h1>Needs</h1>
  
  <p>Enter key has been made disabled in this form page in order to avoid submitting the data mitakenly.</p>
  
  <p><strong>js</strong></p>
  
  <pre><code>function fnCancelEnter()
  {
    if (gCssUA.indexOf("WIN") != -1 &amp;&amp; gCssUA.indexOf("MSIE") != -1) {
      if (window.event.keyCode == 13)
        {
          return false;
        }
    }
    return true;
  }
  </code></pre>
  
  <p>However, in this textarea, I want to enable user to add a break line by pressing Enter key.</p>
  
  <p>I'm sorry but I don't have much knowledge about jQuery and javascript. Please tell me how to do.</p>