show code
<textarea></textarea>
<script>
function doCommand(a){
alert(a);
}
$(document).ready(function(){
$('textarea').focusin(function(){
var _self = this;
var isCtrl = false;
// Bind events.
$(window).keyup( function(e) {
if(e.which==17 || e.which == 91) isCtrl=false;
});
$(window).keydown( function(e){
if(e.which==17 || e.which == 91) isCtrl=true;
if(isCtrl) {
console.log(e.which);
switch(e.which) {
case 66: doCommand('bold');
break;
case 67: doCommand('cut');
break;
case 73: doCommand('italic');
break;
case 86: doCommand('paste');
break;
default: break;
}
return false;
}
});
}).focusout(function(){
$(window).unbind();
});
});
</script>