【问题标题】:How we can identify the position of the character at keydown event?我们如何在 keydown 事件中识别角色的位置?
【发布时间】:2019-05-09 06:00:31
【问题描述】:

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

【问题讨论】:

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

标签: angular ionic3


【解决方案1】:

要知道光标在 keydown/keyup 事件上的位置,我们需要 selectionStart from $event

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-04
    • 1970-01-01
    • 2021-05-24
    • 2015-11-17
    相关资源
    最近更新 更多