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

查看:459
本文介绍了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.

谢谢,

Thanks,

推荐答案

您可以在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天全站免登陆