数学鹅毛笔乳胶 - 如何通过代码移动光标(选择)

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

本文关键字:光标 代码移动 选择 何通过 鹅毛笔      更新时间:2023-09-26

我正在使用mathquill lib(mathquill git),我正在尝试使用html按钮制作键盘和退格键,但我无法弄清楚如何移动光标抛出公式。

谢谢

您可以在 mathquill 中的文本区域上触发自定义键关闭事件,以在公式中移动光标。

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

使用字符代码/键代码/它们是:

  1. 37 为左箭头键
  2. 39 表示右箭头键

谢谢。