views:

514

answers:

2

When pressing enter in contenteditable in chrome, a div is inserted. This interferes with my markup, I need it to be a br.

I know that shift-enter is a br. What is the best way to solve the problem?

Thanks.

Reformulating the question: How do I trigger shift-enter when someone presses enter?

I've tried writing something like this:

$(document).keyup(function hotkeys(e) { 
 if (e.which == 13)
 {
  e = jQuery.Event("keydown")
  e.which = 16;
  $(document).trigger(e);
  e.which = 13;
  $(document).trigger(e);
  alert("trigger");
 }
});

It doesn't work.

Thanks.

A: 

If you want to use jQuery, here is an example from the documentation of replacing one kind of HTML element with another.

John K
+1  A: 

I'm pretty sure everyone has struggled with this issue. Here's a solution: http://www.webdeveloper.com/forum/archive/index.php/t-47633.html

Idris