Created
July 7, 2022 22:14
-
-
Save neodigm/f76f3dcee1a599b30a119932e8b93fb0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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