3

When using contenteditable (on HTML5) you can listen to click/touch and key events to detect when the cursor position changes. It seems on iPad / Safari nothing fires when using a touch event to reposition the cursor.

Is there a method to detect the cursor position change?

Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176

1 Answers1

8

On WebKit and derivatives (including Safari, Chrome and Mobile Safari), and IE, you can use the selectionchange event of the document:

document.onselectionchange = function() {
    console.log("Selection changed!");
};

See also https://stackoverflow.com/a/13881312/96100

Community
  • 1
  • 1
Tim Down
  • 318,141
  • 75
  • 454
  • 536