Solution 1 :

In my opinion one would need to be able to detect that the SHIFT and ENTER keys were pressed. However, the INPUT event does not appear to contain that data. If you can use an event listener that contains data about all keys being used for a single event, then you may be able to use something like event.preventDefault() in the callback. I do not know what the context of all your code is, so I do not know if it is feasible to use other events, specifically keypress.

I also cannot reproduce the issue you are describing. You may be using a plugin that causes the double-spacing issue.

Problem :

I’m creating a barebones in-browser code editor with a pre marked as contenteditable. I’m listening to the input event to perform code highlighting and some other side effects.

When a user hits Shift+Enter two line breaks are inserted which confuses my program and messes up cursor positioning. Is there a way to disable this?

Comments

Comment posted by Shiny

Could you include the HTML of the

Comment posted by Kognise

@Shiny it’s just

Comment posted by Shiny

I’m not able to re-create this issue myself then – Shift Enter is just one line break

Comment posted by Kognise

@Shiny it’s odd, but that’s how it appears in the DOM. However, try getting the

By