0

Is it possible to make an onClick event equal to a combination of keyCodes? I'm trying to make an undo button. What I want is a button's onClick event to be equal to keying down "Command-Z" or "Ctrl-Z".

I can't create the undo feature from scratch. I'm using QuillJS. The undo feature is already built into the program using the keydown method. But there isn't an undo button built into the program. I'm trying to create one that activates the undo keydown event.

1

1 Answer 1

0

When the button is pressed, call the function:

quill.history.undo();

Check out the docs at https://quilljs.com/docs/modules/history/

Answering your question directly, there is no way to trick the quilljs editor into thinking that you pressed control+z in this way.

Sign up to request clarification or add additional context in comments.

3 Comments

I have tried this and an error code always pops up saying "quill" is undefined. I'm don't know how to fix the error code. Have you used QuillJS before?
At some point you should have defined a variable such as "var foo = new Quill(...)". Don't put "quill", but the variable that you defined.
I started another question that can be found at stackoverflow.com/questions/59555447/… I'm still not able to get the undo/redo function working. I was able to create the buttons, but the buttons currently don't do anything. I'm using React-Quill and I haven't had to create a new Quill variable to use the program. I know your function has to work because I've seen it elsewhere, I just can't figure out how to make it work in my code. Can you check out the other post I linked to? I wrote out the code I used. Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.