Created
July 12, 2018 04:25
-
-
Save malikkurosaki/f188aa3fdc3253c73f64385001ea8b73 to your computer and use it in GitHub Desktop.
javascript create simulate key button for controls game like gamepad on screen function - malik kurosaki
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
bt.onclick = function(){ | |
kd() | |
} | |
function kd(e){ | |
var ev = new Event('keydown'); | |
ev.keyCode = 38; | |
document.dispatchEvent(ev) | |
var vv = new Event("keyup"); | |
vv.keyCode = 38; | |
document.dispatchEvent(vv) | |
} | |
document.onkeydown = function(e){ | |
console.log(e.type) | |
} | |
document.onkeyup = function(e){ | |
console.log(e.type) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment