Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to do command enter and preventing enter from being sent to code editor? #144

Open
TheBuilderJR opened this issue Mar 3, 2023 · 7 comments

Comments

@TheBuilderJR
Copy link

tried this to no avail

        onKeyDown={(e) => {
          if (e.key == "Enter" && (e.ctrlKey || e.metaKey)) {
            onSubmit(e);
            return false;
          }
        }}
@jaywcjlove
Copy link
Member

@aleda145
Copy link

aleda145 commented Mar 5, 2023

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?

@jaywcjlove
Copy link
Member

onKeyDown: (evn) => {
if (!other.onKeyDown || other.onKeyDown(evn) !== false) {
shortcuts(evn);
}
},

onKeyDown={(event) => {
+  event.preventDefault();
  console.log(">>>>");
+  return true
}}

@aleda145 Maybe it can solve your problem

@aleda145
Copy link

aleda145 commented Mar 8, 2023

onKeyDown: (evn) => {
if (!other.onKeyDown || other.onKeyDown(evn) !== false) {
shortcuts(evn);
}
},

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! ⭐

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 😄 !

@emptycrown
Copy link

Running into the same issue -- the event cannot be stopped. Any update here?

@Haiqi-Wu
Copy link

Same issue.Any update?

@jaywcjlove
Copy link
Member

onKeyDown: (evn) => {
if (!other.onKeyDown || other.onKeyDown(evn) !== false) {
shortcuts(evn);
}
},

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants