Listen to the undo / redo event in the content value of the div

Is there a way to listen to all the ways in which a user can cause a cancellation of content containing content? For example, when the user presses Control + Z, right-click β†’ Undo or in the file menu Edit β†’ Undo.

I'm not looking for algorithms or implementations for undo / redo, just the ability to listen to the event and overwrite the behavior.

+4
source share
2 answers

Well, Ctrl + Z / Y is possible, but I don’t know about the right key-> Undo / Redo part.

$(document).keydown(function (e) { var thisKey = e.which; if (e.ctrlKey) { if (thisKey == 90) alert('Undo'); else if (thisKey == 89) alert('Redo'); } }); 
+2
source

Control z in How to detect Ctrl + V, Ctrl + C using JavaScript?

for right click you can show the div with the right mouse button How can I capture the right mouse click event in JavaScript?

then when they click the cancel button on the div. just add the onclick function.

0
source

Source: https://habr.com/ru/post/1445186/


All Articles