How to catch enter keypress on textarea but not shift+enter? [duplicate]

Solution 1:

Test for the enter keycode (13) and if shift key was pressed.

...onkeyup = function(e) {
    if (e.keyCode == 13)
    {
//      if (e.shiftKey === true)
        if (e.shiftKey)  // thruthy
        {
            // new line
        }
        else
        {
            // run your function
        }
        return false;
    }
}

Edit: Accept all truthy values of e.shiftKey

Solution 2:

element.onkeydown = function(o) {
  o = o || event;
  if (o.shiftKey && o.keyCode == 13) {
    /* shift + enter pressed */
  }
}