I am making a typewriter like website (here) that uses a textarea and javascript (from button clicks) to add/remove from the textarea.
The next thing I want to add is an indicator to show where the next update (insert/remove) will be so I guess its always at the of the textarea value.
The key details that clash with other solutions are
- The textarea is disabled (+ its a textarea and not a p tag)
- Users add characters by using the buttons and not by typing with their keyboards
- The user isn't selecting or has a selection while typing
- Some solutions involve css that break the website
This is how I insert characters
function insert(char) {
document.getElementById("textarea").value += char
update()
}
to the textarea + a button
<textarea id="textarea" class="textarea" disabled>
</textarea>
<a onclick="insert('1')">
<div class="letterbox">
<p class="typewritter">1</p>
</div>
</a>
(btw I know I spelled typewriter wrong on the website and will fix that later)