My intention:
Let's say you have two players, A and B, playing the same flash game embedded in their page but on two different computers.
If player A presses 'W' to jump or hits "PLAY" to jump, player B should see the same movement in their browser.
What I've already tried:
const game = document.getElementById('game');
var e = null;
game.addEventListener('keydown', (event) => {
if (event.keyCode == 37) {
console.log('Left was pressed');
} else if (event.keyCode == 39) {
console.log('Right was pressed');
};
e = event;
});
I've sent this event over to player B (using sockets)
e = // get it from player A
game.dispatchEvent(e)
This doesn't work. I believe that I need some sort of client side selenium thing so that I can simulate real keypresses onto html elements (in my case it's a flash game). However, I've failed to find one.
Is there a way to do what I want?