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.

Page COW
  • 515
  • 13
  • 31

1 Answers1

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.

Sebi S
  • 63
  • 7
  • 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? – Page COW Dec 31 '19 at 20:20
  • 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. – Sebi S Dec 31 '19 at 20:35
  • I started another question that can be found at https://stackoverflow.com/questions/59555447/how-to-create-undo-redo-buttons-in-quill-js-react-quill 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! – Page COW Jan 02 '20 at 16:51