let inputBoxValue = ""; function onScreenKeyboard() { let inputBox = document.createElement("input"); inputBox.id = "inputBox"; inputBox.style = "opacity: 1; border: none; outline: 0; width: 0%; height: 0%; position: absolute; top: 0px; caret-color: transparent; color: transparent;"; inputBox.type = "text"; document.body.appendChild(inputBox); inputBox.focus(); inputBox.onblur = function () { document.body.removeChild(inputBox); }; inputBox.onkeyup = function () { inputBoxValue = inputBox.value; if (evt.keyCode === 13) { inputBox.blur(); } } inputBox.onchange = function () { inputBoxValue = inputBox.value; // We set this so the inputBox.value doesnt become undefined once we remove it } return inputBox; }// You may need to use an async function or requestAnimationFrame or setInterval to // get the current value of inputBoxValue (the text the user writes)