josdejong / josdejong/jsoneditor
How can I prevent existing keyboard events?
- Dominant language
- JavaScript
- Stars
- 12.3k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Description
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!
Contributor guide
Assessment
This issue has not been assessed yet.