私の見解は、入力を隠すことです(これは多くのアプリがGoogleドキュメント、アトム、vscodeなどのようになります)。そして偽のカーソルと "入力"ボックスを作成します。そのためのコードは、何かのようになります:
var input = document.getElementById('input');
var output = document.getElementById('output');
input.addEventListener('keyup', function() {
output.removeChild(document.getElementById('cursor'));
output.innerHTML += input.value;
input.value = '';
makeCursor();
});
document.addEventListener('click', function() {
input.focus();
});
function makeCursor() {
var cursor = document.createElement('div');
cursor.setAttribute('id', 'cursor');
output.appendChild(cursor);
}
makeCursor();
と私はここで実行可能な例があります。このようhttps://jsfiddle.net/whwv3cb4/2/
を? https://jsfiddle.net/whwv3cb4/ – PaulBGD