JSFiddle - React, Tailwind, and code Playground
by Darker
HTML
<textarea id="wow"></textarea>
JavaScript
var txt = document.getElementById("wow");
//Catch the key down event
txt.onkeydown = function(event) {
var code = event.keyCode;
//alert(code+" "+event.which);
//Convert the code (only letters)
if(code>=65&&code<=90) {
var char = getCharFromCode(code, event.shiftKey);
addChar(this, char);
event.preventDefault();
return false;
}
}
//Function that adds char to value
//Should be modified to use the cursor position (I'm lazy to implement this)
function addChar(input, char) {
input.value+=char;
}
//Conversion function of your choice
function getCharFromCode(code, shift) {
//Reverse the code
code = 65+(25-(code-65));
//Make it small if it's small
if(!shift)
code+=32;
//Return character
return String.fromCharCode(code);
}