Angular 我们如何在按键事件中识别角色的位置?

Angular 我们如何在按键事件中识别角色的位置?,angular,ionic3,Angular,Ionic3,在keydown事件中,我无法确定新插入字符的位置。 还需要知道位置吗?要知道光标在向下键/向上键事件上的位置,我们需要选择从$event开始 yourEvent(event) { const characterPosition = event.selectionStart; console.log('The cursor position on keydown is:', characterPosition); } console.log(event.selectio

在keydown事件中,我无法确定新插入字符的位置。
还需要知道位置吗?

要知道光标在向下键/向上键事件上的位置,我们需要
选择从
$event
开始

  yourEvent(event) {
    const characterPosition = event.selectionStart;
    console.log('The cursor position on keydown is:', characterPosition);
  }

console.log(event.selectionStart)
?为任何偶然发现此问题的人发布答案!请接受:)