Javascript mathquill latex-如何通过代码移动光标(选择)?

Javascript mathquill latex-如何通过代码移动光标(选择)?,javascript,html,latex,mathquill,Javascript,Html,Latex,Mathquill,我正在使用mathquill lib()并尝试使用html按钮制作一个键盘和一个退格,但我不知道如何移动光标并抛出公式 谢谢,您可以在mathquill中的textarea上触发自定义按键事件,以在公式中移动光标 var customKeyDownEvent = $.Event('keydown'); customKeyDownEvent.bubbles = true; customKeyDownEvent.cancelable =true; customKeyDownEvent.charCo

我正在使用mathquill lib()并尝试使用html按钮制作一个键盘和一个退格,但我不知道如何移动光标并抛出公式


谢谢,

您可以在mathquill中的textarea上触发自定义按键事件,以在公式中移动光标

var customKeyDownEvent = $.Event('keydown');

customKeyDownEvent.bubbles = true;
customKeyDownEvent.cancelable =true;
customKeyDownEvent.charCode = 37;  // 37 for left arrow key
customKeyDownEvent.keyCode = 37;   
customKeyDownEvent.which = 37;

$('.mathquill-editable textarea').trigger(customKeyDownEvent);
使用charCode/keyCode/,它们是:

  • 37用于左箭头键
  • 39用于右箭头键
  • 谢谢