Skip to content

Instantly share code, notes, and snippets.

@letsgoawaydev
Last active December 11, 2022 08:10
Show Gist options
  • Select an option

  • Save letsgoawaydev/21227f8da58cfe024c9329c031b72c7e to your computer and use it in GitHub Desktop.

Select an option

Save letsgoawaydev/21227f8da58cfe024c9329c031b72c7e to your computer and use it in GitHub Desktop.
On-Screen Keyboard Code for Mobile Browsers (useful for game dev)
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);
document.getElementById("inputBox").focus();
return inputBox;
}// You may need to use an async function or requestAnimationFrame or setInterval to
// get the current value of inputBox.value (the text the user writes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment