Created
September 23, 2020 10:03
-
-
Save ntakouris/9de35f735e9ffb616abb424a700c260e 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
async function toggleAction(action) { | |
setActionText(action) | |
switch(action) { | |
case 'jump': | |
console.log('jump') | |
var e = new KeyboardEvent('keydown',{'keyCode':32, 'which':32}); | |
document.dispatchEvent(e); | |
break; | |
case 'crouch': | |
var e = new KeyboardEvent('keydown',{'keyCode':40, 'which':40}); | |
document.dispatchEvent(e); | |
break; | |
case 'idle': | |
var e = new KeyboardEvent('keyup',{'keyCode': 40, 'which':40}); | |
document.dispatchEvent(e); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment