react-textarea-code-editor
                                
                                 react-textarea-code-editor copied to clipboard
                                
                                    react-textarea-code-editor copied to clipboard
                            
                            
                            
                        how to do command enter and preventing enter from being sent to code editor?
tried this to no avail
        onKeyDown={(e) => {
          if (e.key == "Enter" && (e.ctrlKey || e.metaKey)) {
            onSubmit(e);
            return false;
          }
        }}
onKeyDown={(event) => {
+  event.preventDefault();
  console.log(">>>>");
}}
@TheBuilderJR https://codesandbox.io/embed/https-github-com-uiwjs-react-textarea-code-editor-issues-144-4yvoij?fontsize=14&hidenavigation=1&theme=dark
I was looking at this package, and got the same issue. Linked codesandbox doesn't work for me (using Firefox/Linux (Pop!)) Enter events will still be sent and be added to the CodeEditor. The same onKeyDown eveent on a normal textarea works as expected though. So might be an issue with how onKeyDown is implemented on the CodeEditor?
https://github.com/uiwjs/react-textarea-code-editor/blob/dedfb991228e9f6687b33d70b81a6e3de300553e/src/index.tsx#L95-L99
onKeyDown={(event) => {
+  event.preventDefault();
  console.log(">>>>");
+  return true
}}
@aleda145 Maybe it can solve your problem
https://github.com/uiwjs/react-textarea-code-editor/blob/dedfb991228e9f6687b33d70b81a6e3de300553e/src/index.tsx#L95-L99
onKeyDown={(event) => { + event.preventDefault(); console.log(">>>>"); + return true }}@aleda145 Maybe it can solve your problem
It doesn't work :/, same problem. Also tried adding event.stopPropagation();, didn't help either. My enter event is still sent to the codeEditor, creating a new line.
The following textArea works as expected for me
<textarea
  onKeyDown={(event) => {
    event.preventDefault();
  }}
></textarea>
Let me know if there anything you want from me to debug this!
Great package, I still use it! :star:
I wanted it to run a SQL query on shift+Enter and not create a new line. But changed to ctrl+space instead, works just as well :smile: !
Running into the same issue -- the event cannot be stopped. Any update here?
Same issue.Any update?
https://github.com/uiwjs/react-textarea-code-editor/blob/dedfb991228e9f6687b33d70b81a6e3de300553e/src/index.tsx#L95-L99
onKeyDown={(event) => { + event.preventDefault(); console.log(">>>>"); + return true }}@aleda145 Maybe it can solve your problem
Maybe I don't understand what it means, haven't solved the problem yet?
@emptycrown @Haiqi-Wu @aleda145