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 can I prevent existing keyboard events? #1542

Open
n4ks opened this issue Aug 9, 2023 · 1 comment
Open

How can I prevent existing keyboard events? #1542

n4ks opened this issue Aug 9, 2023 · 1 comment
Labels

Comments

@n4ks
Copy link

n4ks commented Aug 9, 2023

Good day!
I am using the editor in Tree mode to view data without the ability to edit.
To prevent keyboard input and allow copying I used onEvent:

   const isCopyEvent = evt.code === 'KeyC' && evt.ctrlKey; 
    if (
      evt.type === 'input' ||
      evt.type === 'paste' ||
      evt.type === 'keyup' ||
      evt.type === 'keydown'
    ) {
      if (!isCopyEvent) {
        evt.preventDefault();
      }

This works great for "native" events. But I don't understand how to prevent events that already exist in the library - such as ctrl + M, ctrl + D and so on. Is there any way to "unsubscribe" from them?

The events I'm talking about are in the onKeyDown() method

Thanks!

@josdejong
Copy link
Owner

I think the only way is to alter the Node.prototype.onEvent method, wrap it with your own variation.

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

No branches or pull requests

2 participants