【问题标题】:mathquill latex- how can I move cursor (selection) by code?mathquill latex-如何通过代码移动光标(选择)?
【发布时间】:2014-12-07 11:44:45
【问题描述】:

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

谢谢,

【问题讨论】:

    标签: javascript html latex mathquill


    【解决方案1】:

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

    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/ 分别是:

    1. 37 代表左箭头键
    2. 39 右箭头键

    谢谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-10
      • 1970-01-01
      • 2019-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多