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

Keyhandler #746

Open
TomasLongo opened this issue Apr 27, 2019 · 8 comments
Open

Keyhandler #746

TomasLongo opened this issue Apr 27, 2019 · 8 comments

Comments

@TomasLongo
Copy link

Hi,

is there a way to add custom keyhandlers?

My case: I want to listen to ctrl + enter in order to save my doc.

Thanks in advance,
Tomas

@khaydarov
Copy link
Member

@TomasLongo Hi!
Editor.js provides API to save the contents outside the instance

var editor = new EditorJS();
editor.save(); // here editor saves your data and returns JSON object

You can wrap method save(), like

document.addEventListener('keydown', function() {
  // here you need to check CTRL+ENTER press before firing `save` method
  editor.save().then(...);
}, false);

OR another easier way is to use some library for shortcuts
We provide our own: https://github.com/codex-team/codex.shortcuts

@TomasLongo
Copy link
Author

TomasLongo commented Apr 28, 2019

@khaydarov Thanks for getting back.

The actual saving is not the problem. Im not able to capture the ENTER key (CTRL works, though).
I tried the lib you suggested.

It seems like ENTER is intercepted by the editor.

Am I missing something?

Tomas

@khaydarov
Copy link
Member

@TomasLongo
Yes, ENTER keypress is intercepted by the Editor, but only inside the Block or when Block is focused. The problem is that we prevent default behaviour and stop propagation that's why you are not able to capture ENTER.
We're working on this problem

@TomasLongo
Copy link
Author

Thanks for replying. Glad to here that you're working on this.

Does an issue exist on that topic, which I could subdscribe to?

@romainhe
Copy link

Any news or workaround to capture enter key event ?

@bencohendev
Copy link

I'm also interested in whether any progress has been made here. I need to be able to intercept and stop enter

@jeasoncc
Copy link

hey, any news ?

@calumk
Copy link

calumk commented Sep 25, 2022

i think This is required to help fix some issues in my columns plugin @calumk/editorjs-columns

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

6 participants