Trigger Ctrl + z & Ctrl + y button click

I highlighted two split buttons for Ctrl+ zand Ctrl+ y. I want the Ctrl+ zand Ctrl+ functions to be yexecuted at the click of a button.

To achieve this, I try to call the Ctrl+ zand Ctrl+ ybuttons when the button is pressed, but they do not start.

The code I have written so far:

case "undo":
    var press = jQuery.Event("onkeydown");
    press.ctrlKey = true;
    press.keyCode = 90;
    jQuery(".excellentableEditSpread").trigger(press);
    break;

case "redo":
    var press = jQuery.Event("onkeydown");
    press.ctrlKey = true;
    press.keyCode = 89;
    jQuery(".excellentableEditSpread").trigger(press);
    break;
+4
source share
1 answer

You can try the following:

function doUndo(){
  document.execCommand('undo', false, null);
}

function doRedo(){
  document.execCommand('redo', false, null);
}
+3
source

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


All Articles