Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

Thanks,

like image 326
Roy Avatar asked Oct 21 '25 06:10

Roy


1 Answers

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.

like image 166
Kunal Manchekar Avatar answered Oct 23 '25 19:10

Kunal Manchekar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!