JSFiddle - React, Tailwind, and code Playground
by ecmanaut
HTML
<div contenteditable="true" id="editor">Please type something in here, not in the textarea below, and I'll show input and touch events</div>
<textarea id="log" rows="10" cols="40" readonly></textarea>
JavaScript
const ed = document.getElementById("editor");
const log = document.getElementById("log");
ed.addEventListener("input", function(e) {
log.value = `input#${e.inputType}\n${log.value}`;
}, false);
['touchstart', 'touchmove', 'touchend', 'touchcancel'].forEach(n => {
ed.addEventListener(n, function(e) {
log.value = `${n}#${e.touches.length}\n${log.value}`;
}, false);
});