JSFiddle - React, Tailwind, and code Playground

by Joshua Koudys

HTML

<input type="text" id="q" value="sample"/>

CSS

input { font-family: courier; letter-spacing: 1em; }

JavaScript

var input = document.getElementById('q');
input.addEventListener('keypress', function(event){
    debugger;
    event.preventDefault();
    var s = this.selectionStart;
    this.value = this.value.substr(0, s) + String.fromCharCode(event.keyCode) + this.value.substr(s + 1);
    this.selectionEnd = s;
}, false);