Skip to content

Instantly share code, notes, and snippets.

@malikkurosaki
Created July 12, 2018 04:25
Show Gist options
  • Save malikkurosaki/f188aa3fdc3253c73f64385001ea8b73 to your computer and use it in GitHub Desktop.
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
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