react-quill
react-quill copied to clipboard
How to disable newlines (Act as input) in react-quill 2.0.0
Hi there,
I've googled and googled but really can't see a way to disable newlines/enters for ReactQuill. I see plenty of posts for regular Quill but I'm not too sure how different the APIs/functionalities are.
Unfortunately, when I use my component like below.
<ReactQuill
onKeyUp={(e) => handleKeyDown(e)}
formats={["header"]}
modules={{
toolbar: false,
}}
ref={props.quill}
/>
const handleKeyDown = (e) => {
if (e.keyCode === 13) {
e.preventDefault()
}
}
I call handleKeyDown(e)
which gets triggered but when calling e.preventDefault()
it does not work for the enter key (It's called and definitely reached!). However, it will work for any other key and if I only call e.preventDefault()
it will stop every key except the enter button.
Any help as to why this doesn't work would be greatly appreciated.
up
up