Custom Events to simulate a click

Attempting to make a custom event which simulates a button click so I can use a phone numpad to click a button. inputState.center is the enter key which I’m using just to test on the computer first.

if(document.createEvent)
{
pushPlayBtn.dispatchEvent(new CustomEvent(‘onmousedown’));
if (inputState.ok == 1 || inputState.center == 1 ){
console.log(“Debug Start”);
menuBg.destroy();
pushPlayBtn.destroy();
slideTween.restart();
conveyor1Tween.restart();
conveyor2Tween.restart();
this.buttonSound.play();
console.log(“Debug End”);
}
};

dispatchEvent is not a function, and when I change this to emit I get no errors, but it still does not work. Any Ideas would help greatly, but I understand not many people have experience with old school phone numpads.

What I’m really after here is clicking an object but using another key to simulate the click.

Wild. I didn’t know you could even run a modern browser on one of those. What model is this anyways?

That aside, assuming you are able to access the internet from this ancient phone, maybe try this site: https://keycode.info/

and then use a vanilla js keycode event to detect it?

The phone model is called Jio, they’re based in India, very bad resolution, the screen size is 240 X 320 pixels. It runs on KaiOS which is based off of an old Mozilla build, so they can run HTML5 JavaScript games. We might be the first people to code something like this, so it is pretty uniquely interesting.

But, yes we’ve been trying to simulate a click on the area where a button is when pressing a numberpad button. I’m sure it’s not super complex code, but since no one has really done it before there are zero examples. I will keep plugging away at it and once I figure it out I will be sure to share my results.

Was a matter of variables being outside the scope. So just so everyone knows even though I’m sure no one really cares, you can get phaser to work with these low budget phones and numpads. You will need the handle keys for the numpad you’re using.

2 Likes