I'm looking for a way that in a contentEditable when doing 'shift + enter' do the same as when you press just the 'enter' key what it does is put the content inside a div instead of just adding a br.
I try disabling the shift key, but no results :( hope you can help me
<div class="editableDiv" contentEditable="true"><b>Hello</b> world.</div>
div{
color: green;
}
.editableDiv{
color: salmon;
}
$('.editableDiv').on('keydown', function(event) {
if (event.keyCode == 13 && !event.shiftKey) {
console.log('pure enter');
} else if (event.keyCode == 13 && event.altKey) {
console.log('triggered enter');
$(this).trigger(jQuery.Event("keydown", {
keyCode: 13,
altKey: false
}));
}
});
Need trigger just press 'enter' key when press 'shift + enter'