views:

95

answers:

0

I've written a bit of code in my keyboard event handler to insert a <br> in response to the press of the Enter key:

event.preventDefault();
document.execCommand('InsertHTML', true, '<br>');

This only works if the cursor is between two Letters, if its on the end i need two <br>-Elements. Can i detect if i'm on the end of a Line? Or some other working idea for the Enter problem?

I also tried to catch the normal key-event (wothout the ctrl-Key pressed) and create a keyboard-event with JS where the Enter Key is pressed together with the ctrl. But this dosn't work…

It only has to Work in Webkit/Safari…