jQuery Trigger keyCode Ctrl+Shift+z & Ctrl+z in wysiwyg textarea

itsme picture itsme · Oct 13, 2011 · Viewed 16.1k times · Source

i was wondering how do i trigger the event keyCode composed by Ctrl+z and the event keycode composed by Ctrl+Shift+z ?

Answer

aziz punjani picture aziz punjani · Oct 13, 2011

Use e.which which has been normalized cross browser by jquery.

$(document).keydown(function(e){
      if( e.which === 90 && e.ctrlKey && e.shiftKey ){
         console.log('control + shift + z'); 
      }
      else if( e.which === 90 && e.ctrlKey ){
         console.log('control + z'); 
      }          
});