I\'m using this function in order to replace with in break lines on contentEditable divs using Safari an
First, use keyup as the event name, keypress works only on Firefox.
Second, e.which is not always available. Use e.keyCode primarily, and fall back to e.which:
var code = e.keyCode || e.which;
if (code == 13) {
// your code here..
}
Third, if you need to cancel default events fired in the key-press, you might want to throw in a preventDefault() inside your event handler routine. Make sure it's the first line.
function(e){
e.preventDefault();
..
}