Sometimes, developer wants to know where the user attempts to move the caret in an editor, regardless whether it will actually succeed.
For example, when the caret is already after the last character in the editor, if the user still presses the "move-forward" arrow(Say, right/down arrow in a horizontal-tb or vertical-lr editor; or left/down arrow in a vertical-rl editor) to continue moving forward, it will fail, but the developer may sometimes want to be informed of the user's failed attempt.
One specific usage of such an event is implementing a syntax hightlighted editor, where each syntax unit is emulated by a contenteditable wrapup. Being able to informed of such failed attempts, it can be ensured technically correct to move among syntax units, without doing hacky code which may results in portability problems.
Thoughts about this? I look forward to hearing from you.
Sometimes, developer wants to know where the user attempts to move the caret in an editor, regardless whether it will actually succeed.
For example, when the caret is already after the last character in the editor, if the user still presses the "move-forward" arrow(Say, right/down arrow in a horizontal-tb or vertical-lr editor; or left/down arrow in a vertical-rl editor) to continue moving forward, it will fail, but the developer may sometimes want to be informed of the user's failed attempt.
One specific usage of such an event is implementing a syntax hightlighted editor, where each syntax unit is emulated by a contenteditable wrapup. Being able to informed of such failed attempts, it can be ensured technically correct to move among syntax units, without doing hacky code which may results in portability problems.
Thoughts about this? I look forward to hearing from you.