jsoneditor
jsoneditor copied to clipboard
How can I prevent existing keyboard events?
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!
I think the only way is to alter the Node.prototype.onEvent
method, wrap it with your own variation.