Add custom shortcut in the notes editor (tinyMCE) [tuto]


To add a shortcut to remove format and for upperscript:


Go to C:\Program Files (x86)\Zotero
backup zotero.jar
Copy past zotero.jar on desktop
Open it (with 7zip)
edit zotero\resource\tinymce\note.html


Find the line setup: function (ed) { **

( just beneath setLocale(ed); add this:

//***shortcut remove format (ctrl+space)

ed.shortcuts.add('ctrl+32', 'remove formatter', function(){

tinymce.activeEditor.execCommand('RemoveFormat');

});



//***shortcut upperscript () :

ed.shortcuts.add('ctrl+;', 'upper script', function(){

tinymce.activeEditor.execCommand('superscript');

});

ps: it might not be "function (ed)" but "function (editor)". So just replace "ed.shortcuts.add" by "editor.shortcuts.add"

ps2: For the syntax of shortcut (eg. 32 = space) use: cf http://keycode.info . You can test it: https://goo.gl/9D9Zpa )
  • It works perfectly, thanks so much!

    In case anyone else wants subscript & superscript to work the same way it does in Word, use this code instead of the upperscript shortcut in the above comment:

    //***shortcut upperscript () :

    editor.shortcuts.add('ctrl+Shift+=', 'upper script', function(){

    tinymce.activeEditor.execCommand('superscript');

    });

    //***shortcut lowerscript () :

    editor.shortcuts.add('ctrl+=', 'lower script', function(){

    tinymce.activeEditor.execCommand('subscript');

    });
Sign In or Register to comment.