I have a div with contenteditable set and I am capturing keypress using jquery to call preventDefault() when the enter key is pressed. Similar to this question which insert
var r = getSelection().getRangeAt(0);
r.insertNode(r.createContextualFragment('Hello'));
//select this range
getSelection().removeAllRanges();
getSelection().addRange(r);
//collapse to end/start
getSelection().collapseToEnd()