0

i have a content editable div, i want to disable the undo operation i.e control + z operation on the editable div, i tried like this

 //key up handles all keypresse events. Backspace wont fire for simple keypress event in jquery $("#Partner").keyup(function (e) { if (e.keyCode == 90) { e.preventDefault(); return; } 

still i am able to perfrom undo operation, any input on how to disable undo on editable div?

2
  • 1
    why do you want to do this? Commented Mar 19, 2014 at 18:42
  • sharepoint edit control does not allow user to make undo, we need same one in our aps so Commented Mar 19, 2014 at 18:44

2 Answers 2

1

Here is the solution

 $("#Partner").keydown(function (e) { if (e.keyCode == 90 && e.ctrlKey) { e.preventDefault(); return; } }); //key up handles all keypresse events. Backspace wont fire for simple keypress event in jquery $("#Partner").keyup(function (e) { if (e.keyCode == 90 && e.ctrlKey) { e.preventDefault(); return; } 
Sign up to request clarification or add additional context in comments.

Comments

0

Try this...

$("#Partner").bind("keydown", function (e) { if (e.keyCode == 90 && e.ctrlKey) { e.preventDefault(); return; } } 

Note: the key operations are performed in the keydown operation also. so try to prevent the keydown event to block the default behavior.

1 Comment

i got solution, we need to handle both keydown and keyup

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.