Última vez eu adicionei um atalho de teclado que estava usando jQuery. Dê uma olhada no jquery.hotkeys plugin que permite que você ative os atalhos de teclado com um simples forro :
$(document).bind('keydown', 'ctrl+a', fn);
atualização
se você quiser verificar se o editor TinyMCE está ativo e tem um texto selecionado, então aqui estão as funções que você precisa:
function isTinyMCEactive(){ //check if editor is active
is_tinyMCE_active = false;
if (typeof(tinyMCE) != "undefined") {
if (tinyMCE.activeEditor == null || tinyMCE.activeEditor.isHidden() != false) {
is_tinyMCE_active = true;
}
}
return is_tinyMCE_active;
}
function tinyMCEhotkeys(tag){
if (isTinyMCEactive()){
var selected_content = '';
selected_content = tinyMCE.activeEditor.selection.getContent();
if (selected_content != '' || selected_content != null){ //check if editor has selection
tinyMCE.activeEditor.execCommand("mceInsertContent", 0, '<' + tag + '>' + selected_content + '</' + tag + '>');
}
}
}
agora, depois de ter essas funções, o resto é fácil:
$(document).bind('keydown', 'ctrl+1', tinyMCEhotkeys('h1'));
$(document).bind('keydown', 'ctrl+2', tinyMCEhotkeys('h2'));
$(document).bind('keydown', 'ctrl+3', tinyMCEhotkeys('h3'));
$(document).bind('keydown', 'ctrl+4', tinyMCEhotkeys('h4'));