5 <div>When the caret reaches the edge of the input box or content editable div, on the next input if must jump to the center of the control.
</div>
6 <span style=
"position:absolute; visibility:hidden" id=
"single-digit">0</span>
7 <div style=
"border:thin solid black; white-space:nowrap; overflow:hidden" contenteditable=
"true" id=
"input-contenteditable">012345678901234567890123456789</div>
10 var contentEditable
= document
.getElementById("input-contenteditable");
11 var singleDigitWidth
= document
.getElementById("single-digit").clientWidth
;
12 var contentEditableSize
= 10;
13 contentEditable
.style
.width
= (singleDigitWidth
* contentEditableSize
) + "px";
14 contentEditable
.focus();
15 // Move the caret to the beginning of the input.
16 getSelection().collapse(contentEditable
.firstChild
, 0);
17 var editableContent
= contentEditable
.textContent
;
18 if (window
.eventSender
) {
19 for (var i
= 0; i
< contentEditableSize
* 1.2; ++i
)
20 eventSender
.keyDown(editableContent
[i
]);