mathquill latex- how can I move cursor (selection) by code?

后端 未结 1 486
陌清茗
陌清茗 2021-01-16 04:25

I am using mathquill lib (mathquill git) and I am trying to make a keypad and a backspace using html buttons but I can\'t figure out how to move the cursor throw the formula

相关标签:
1条回答
  • 2021-01-16 04:59

    You can trigger custom keydown event on textarea within mathquill to move cursor through formula.

    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);
    

    Use charCode / keyCode / which are:

    1. 37 for left arrow key
    2. 39 for right arrow key

    Thanks.

    0 讨论(0)
提交回复
热议问题