Skip to content

Instantly share code, notes, and snippets.

@neodigm
Created July 7, 2022 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neodigm/f76f3dcee1a599b30a119932e8b93fb0 to your computer and use it in GitHub Desktop.
Save neodigm/f76f3dcee1a599b30a119932e8b93fb0 to your computer and use it in GitHub Desktop.
document.addEventListener("keyup", function( ev ){
let elKey = null
let sKeyVal = ev.key.toLowerCase()
if( sKeyVal ){
if( sKeyVal == "backspace" ) sKeyVal = "bs"
if( sKeyVal == "enter" ) sKeyVal = "cr"
elKey = WrdKey.getKeyEl( sKeyVal )
if( elKey ){ // Simulate Tap
const evMD = new MouseEvent('mousedown', {view: window, bubbles: true, cancelable: true })
const evMU = new MouseEvent('mouseup', {view: window, bubbles: true, cancelable: true })
elKey.dispatchEvent( evMD )
setTimeout(function(){ elKey.dispatchEvent( evMU ) }, 256)
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment