How to use javascript to call the "Ok" or "Enter" button press?

I have a section where the player is surfing, and will automatically move forward unless you hold in a direction to change directions.

I'm using a parallel process for this and it's working great except for one thing; I cannot for the life of me figure out how to let the player actually stop surfing at a vehicle on/off point because they need to be able to press Enter to get out of the vehicle.
I figure all I really need to do is use a conditional branch with the "Okay" key being pressed down, and a Javascript command to tell the game to use the "Okay" key input, but for the life of me, I cannot find anywhere online or in the help file to do that.

Could someone help me out here? Thanks!
It's Input.isTriggered('ok') afaik
You will need a plugin to send virtual input. Why don’t you just put events where the player lands that stops the surfing? If the problem is because your using a vehicle as the surf board you can probably find a script to exit the vehicle. You could also just not use a vehicle and just change the players graphic and speed.
It's Input.isTriggered('ok') afaik

Unfortunately this didn't work. I guess I would need a plugin after all like Rugman said.

You will need a plugin to send virtual input. Why don’t you just put events where the player lands that stops the surfing? If the problem is because your using a vehicle as the surf board you can probably find a script to exit the vehicle. You could also just not use a vehicle and just change the players graphic and speed.

Yeah it's a vehicle. I've tried at length to event getting off of the vehicle while the parallel process for moving automatically is on, but I can't seem to get it.

I thought about eliminating the vehicle portion, but I wasn't sure how to go about doing that using Yanfly's region restrictions. Is there a way to make it so some regions are passable only when a switch is turned on?
Input.isTriggered('ok') just checks if the ok button is actually pressed. There should be a simple method to achieve what you need without virtual input though.

Edit: Sorry didn't see your other post. If you post a screenshot of your events, I can probably help you out more.
What you ask for is actively discouraged and blocked by most browsers.
Just think about it: if a HTML-based program can simulate a keypress, then an infected website would also be able to simulate typing in your administrator passwort when windows tries to block access to prevent infection.

What should usually be done is looking for the function that you want to trigger with the input, and call that directly without going through the actual input buffer.
But to help you with that, we would need to get more details like screenshots of your event pages like asked by the poster above.
The function I know is this, but it's only for RMMZ:
JavaScript:
Input.virtualClick('ok')

Someone would have to recreate it as a Plugin for RMMV.

Spoiler: Topic with similar subject that might help:

Good luck

Edited:

Try this:
There's a Get on/off Vehicle event command, have you tried using that instead?

It's easy to simulate an input: just change the appropriate variable, e.g. Input._currentState["ok"] = true. That said, unless I've missed something, it would be pointless to simulate an OK input when the player presses OK: the game has already recognised that input! By default player move controls are suspended while the player is undergoing a move route, so I think you'd want something to change how the game reacts to the input.

Maybe share your event setup?
That said, unless I've missed something, it would be pointless to simulate an OK input when the player presses OK:
you missed something: the OP want to get the OK press WITHOUT the player pressing anything.
That is why I posted above that this is approaching very critical options and should be done differently.
If you want to force entry and exit of a vehicle, you will only need to use the event commands:

RPG Maker MV > Event Commands > Flow Control -> Conditional Branch -> Vehicle
RPG Maker MV > Event Commands > Movement -> Set Vehicle Location
RPG Maker MV > Event Commands > Movement -> Get on/off Vehicle

References:
If you want to force entry and exit of a vehicle, you will only need to use the event commands:

RPG Maker MV > Event Commands > Movement -> Set Vehicle Location
RPG Maker MV > Event Commands > Movement -> Get on/off Vehicle

References:

That's not the problem. The problem is that once I have my parallel process active to make you start moving forward automatically, it won't allow for checking for an OK input, to activate the event for Get On/Off Vehicle.

Here's the parallel process that activates when you get into the boat, and start surfing:

◆If:Button [Down] is pressed down ◆Set Movement Route:Player (Skip) : :◇Move Down ◆ :Else ◆If:Button [Left] is pressed down ◆Set Movement Route:Player (Skip) : :◇Move Left ◆ :Else ◆If:Button [Right] is pressed down ◆Set Movement Route:Player (Skip) : :◇Move Right ◆ :Else ◆If:Button [Up] is pressed down ◆Set Movement Route:Player (Skip) : :◇Move Up ◆ :Else ◆If:Button [OK] is pressed down ◆>>>[B]This is the problem area[/B]<<< ◆ :Else ◆Set Movement Route:Player : :◇1 Step Forward ◆ :End ◆ :End ◆ :End ◆ :End ◆ :End

Note that I can't simply put Get On/Off Vehicle where the OK is pressed, because they could get off at any point in the map. I want you to only be able to get on and off on certain tiles, hence why I'm using Yanfly's vehicle restrictions. But as long as the game is moving you forward, it won't let you interact with the get on/off docking point.
I strongly suggest you rework that parallel process by not using any else-branch - best perhaps to disable the else completely by unchecking the box for it in the conditional branch window.
this will make the event much better readable and slightly spped it up without any negative cause, because if one button is pressed the others are handled independently.

It also has a chance of making the OK work correctly - I'm not sure of that however, just test it out.
Note that I can't simply put Get On/Off Vehicle where the OK is pressed, because they could get off at any point in the map.
Have you actually tested this? The YEP Vehicle Restrictions plugin adjusts the isLandOk method directly, which determines whether a location is OK for disembarking a vehicle. The Get on/off Vehicle command goes through the same process as the standard controls: if it's not a valid on/off location then nothing will happen.
I strongly suggest you rework that parallel process by not using any else-branch - best perhaps to disable the else completely by unchecking the box for it in the conditional branch window.
this will make the event much better readable and slightly spped it up without any negative cause, because if one button is pressed the others are handled independently.

It also has a chance of making the OK work correctly - I'm not sure of that however, just test it out.

Already tried it without Else branches, and it worked exactly the same.

Have you actually tested this? The YEP Vehicle Restrictions plugin adjusts the isLandOk method directly, which determines whether a location is OK for disembarking a vehicle. The Get on/off Vehicle command goes through the same process as the standard controls: if it's not a valid on/off location then nothing will happen.

Yes. My understanding is that as long as the parallel process is running, it's going to always check if you move forward, which cancels out the check if you're pressing Okay to disembark.

The Get On/Off Vehicle event location with the landing ID works perfectly fine when I don't have the parallel process running to keep you moving forward.

At this point I'm considering tossing out the idea and just letting the player stop in place, even if it doesn't make sense.
The Get On/Off Vehicle event location with the landing ID works perfectly fine when I don't have the parallel process running to keep you moving forward.
then make the OK button the first button to check in the parallel, and make it the only one with an else-branch.
Place the other direction checks into that else-branch.

again not tested by me, but this should disable the other movement as soon as the OK button is pressed, allowing you to use get on/off vehicle (perhaps with a wait) in the branch when OK is being pressed
I strongly suggest you rework that parallel process by not using any else-branch - best perhaps to disable the else completely by unchecking the box for it in the conditional branch window.
this will make the event much better readable and slightly spped it up without any negative cause, because if one button is pressed the others are handled independently.
using an else branch actually should produce a slight improvement in speed, since instead of always scanning every button every frame, it stops scanning buttons if it finds one that's being held down.


I'm using a parallel process for this and it's working great except for one thing; I cannot for the life of me figure out how to let the player actually stop surfing at a vehicle on/off point because they need to be able to press Enter to get out of the vehicle.
Anyway, here's my solution:

Wrap all of the vehicle moving code in your parallel process into an if statement that checks the player's region.

Paint your vehicle disembarking areas with a particular region. If the player is in that region, the forced movement code doesn't run. This is also an obvious signal to the player that this is a place they can get off their vehicle.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-use-javascript-to-call-the-ok-or-enter-button-press.137031/