Reputation: 1243
I need to handle the events undo and redo myself when a user selects undo/redo from context menu or presses ctrl z in a textarea. How can i prevent the default behavior and add custom behavior.
Upvotes: 2
Views: 1530
Reputation: 94101
You can detect ctrl+z
on keyup()
with:
var ctrlZ = e.ctrlKey && e.which === 90
if (ctrlZ) { ... }
And context menu on mousedown()
with:
var rightClick = e.which === 2
if (rightClick) { ... }
Upvotes: 4