问题
I am working on TinyMCE editor where I have to customize it for some special equation. The problem is that when I press the enter key, the cursor goes to new line. My question is how to prevent the cursor from jumping to new line when someone press the enter key inside the editor.I want to cursor to remain where it is before, on pressing the enter key. Just like textarea, when the enter key is pressed, the cursor goes to new line. Can anyone explain how to prevent the cursor from jumping to new line.
Thanks.
回答1:
I think you can capture the Enter key by using
$(document).keypress(function(e) {
if(e.which == 13) {
// enter pressed
}
});
This will capture the key in the whole document though
来源:https://stackoverflow.com/questions/18935913/how-to-prevent-the-cursor-from-jumping-to-next-line-in-textarea-using-jquery