I managed to do it a different way. Goto Markdown.Editor.js and look after an input event function, let's say the following function
util.addEvent(panels.input, "keypress", function (event) {
// keyCode 89: y
// keyCode 90: z
if ((event.ctrlKey || event.metaKey) && (event.keyCode == 89 || event.keyCode == 90)) {
event.preventDefault();
}
});
and then modify it to get your mathjax updated as follows:
util.addEvent(panels.input, "keypress", function (event) {
// keyCode 89: y
// keyCode 90: z
if ((event.ctrlKey || event.metaKey) && (event.keyCode == 89 || event.keyCode == 90)) {
event.preventDefault();
}
var previewID=this.id.replace("input","preview");
window.setTimeout(function(){MathJax.Hub.Queue(["Typeset", MathJax.Hub, previewID]);},10);
});
The purpose of the setTimeout is confirm MathJax run after the keypress event is passed. I sat it to 10 ms, but you may change it to match your needs.
This way is not as efficient as that of stack exchange but works well.