Modify undo/redo behaviour on a textarea using jquery

前端 未结 1 581
-上瘾入骨i
-上瘾入骨i 2021-01-15 04:44

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

相关标签:
1条回答
  • 2021-01-15 05:11

    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) { ... }
    
    0 讨论(0)
提交回复
热议问题