mousetrap
mousetrap copied to clipboard
Tinymce 4 support
hello i have problem with tinymce editor i use the global plugin, this code not working inside tinymce, any suggestion?
Mousetrap.bindGlobal(['ctrl+s', 'command+s'], function (e) {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
my_func_here();
});
When an editor is rendered you can bind mousetrap to the editor's (iframe) body element.
function handleSaveKeyboardShortcut(e) {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
my_func_here();
}
Mousetrap.bindGlobal(['ctrl+s', 'command+s'], handleSaveKeyboardShortcut);
// When an editor is rendered...
Mousetrap(editor.contentWindow.document.body).bind(['ctrl+s', 'command+s'], handleSaveKeyboardShortcut);
thank you! @mattheyan