mathquill latex-如何通过代码移动光标(选择)? [英] mathquill latex- how can I move cursor (selection) by code?

查看:39
本文介绍了mathquill latex-如何通过代码移动光标(选择)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

谢谢,

推荐答案

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

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

使用charCode/keyCode/分别是:

Use charCode / keyCode / which are:

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

谢谢.

这篇关于mathquill latex-如何通过代码移动光标(选择)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆