Check for keyboard input.

Can you check for keyboard input with a script but no plugin?

if "key" is pressed

stuff

{else} different stuff
You can. Input.isPressed(keycode). You can find more details in rpg_core.js
9: 'tab', // tab
13: 'ok', // enter
16: 'shift', // shift
17: 'control', // control
18: 'control', // alt
27: 'escape', // escape
32: 'ok', // space
33: 'pageup', // pageup
34: 'pagedown', // pagedown
37: 'left', // left arrow
38: 'up', // up arrow
39: 'right', // right arrow
40: 'down', // down arrow
45: 'escape', // insert
81: 'pageup', // Q
87: 'pagedown', // W
88: 'escape', // X
90: 'ok', // Z
96: 'escape', // numpad 0
98: 'down', // numpad 2
100: 'left', // numpad 4
102: 'right', // numpad 6
104: 'up', // numpad 8
120: 'debug' // F9

ok so I tested and found (per lines 3003-3026)

Input.isPressed('ok')
this is triggered by enter and spacebar as both are equally "ok"
how do I get it to trigger for spacebar but not enter
would It simply be Input.isPressed(32: 'ok')
Simply assign "space" and "enter" different keycodes.
Can you give me an example of how to do that please and thank you?
In your previous post you even copy pasted the right excerpt of the code:
9: 'tab', // tab
13: 'ok', // enter
16: 'shift', // shift
17: 'control', // control
18: 'control', // alt
27: 'escape', // escape
32: 'ok', // space
33: 'pageup', // pageup
34: 'pagedown', // pagedown
37: 'left', // left arrow
38: 'up', // up arrow
39: 'right', // right arrow
40: 'down', // down arrow
45: 'escape', // insert
81: 'pageup', // Q
87: 'pagedown', // W
88: 'escape', // X
90: 'ok', // Z
96: 'escape', // numpad 0
98: 'down', // numpad 2
100: 'left', // numpad 4
102: 'right', // numpad 6
104: 'up', // numpad 8
120: 'debug' // F9

13, 27, etc. these are the ASCII numbers behind the keys.
The right part behind the // explains what key it is on the keyboard.
The middle part inside the ' ' is the symbol, the most important thing.
When you see two same symbols at a different key, that means those two keys are "the same key".
Enter, Space and Z have the same symbol, 'ok'. So in translation Enter, Space and Z do the same thing. If you don't want them to do the same thing, just rename one of them, preferably the one that you don't want to be doing anything.
For example if you rename space's symbol from 'ok' to 'left', it will serve as a left arrow instead of an "ok" key. If you rename space's symbol to a completely custom symbol, it won't do anything other defined keys do.
So for example if I rename the space symbol from 'ok' to 'space', I can then define space to do completely custom stuff.
if (Input.isPressed('space')) alert ("Space now shoots an alert window!")
To rename the symbol I have to alter the .js file and save it, correct?
No need to.
You can create a js plugin and use
Input.keyMapper[asciicode of the key you want to change] = 'new symbol'. Ascii codes of already used keys are inside rpg_core.js, other ascii codes can be found in an ascii table, there's a lot of them out there.
Thanks but I'm hoping to avoid plugins at this time. I'll have to try something different.
There's no difference between using a plugin and editing the core scripts as long as you're reasonable about it. Also,
how do I get it to trigger for spacebar but not enter
cannot be achieved without scripting in MV.
Oh no I like scripting I just don't like plugins. I'm all about monstrous events with lots of script commands. Lol
Oh no I like scripting I just don't like plugins. I'm all about monstrous events with lots of script commands. Lol
That's kind of bizarre to like one and not the other because they're both Javascript. Plugins are generally better, for 3 main reasons (these are general reasons and not necessarily specific to this situation):
  1. Efficiency - Plugins are parsed before the game starts whereas script event commands are parsed when the game is running. The parsing is the same speed for both but one occurs when the player expects loading and the latter occurs when the player expects to be playing. It might not be noticeable lag for some script commands, but for others it could add up
  2. Conceptually - Things such as the controls should be set up when the game starts, if you don't want a certain key to do a certain thing, it wold be weird for it to work on the title screen but then not work later after some event is executed
  3. Error handling - If there's an error in a plugin, the stack trace will reveal the exact line number that errored, and you can even set breakpoints to step through those lines one-by-one to find the error. If there's an error in an event script call, because it is eval'ed you don't get the line number that errored and you don't even get when event errored.
Well I have thousands of hours on MV, but no official training in java script, only what i've taught myself and what i've been able to learn from patient pros who answer the questions that i ask. bizarre or not, thanks for your help, this issue was already answered anyhow.
"bizarre" was a poor word choice, substitute "inconsistent" and that better expresses the point I was trying to make. Sorry about that.

Well I have thousands of hours on MV, but no training in java, so bizarre or not, thanks for adding something constructive to this conversation....

Not sure if that's sarcasm or not. If it isn't, then no problem, glad to help.

If it is sarcasm, then I'll add something more explicitly constructive to take away from this:
Event commands, script commands, plugins are just tools, each with their own strengths and weaknesses (such as I described above). You'll be best served in the future to choose a tool based on its strengths and weaknesses rather than whether you "like" it or not.
If you do decide to research the scripting aspects more, make sure to look up "Javascript" and not "Java", otherwise you'll find some non-useful information.

You are, of course, free to take or ignore this advice however you please.
I opened this thread asking if this can be done with a script but not a plugin...

Original thread: https://forums.rpgmakerweb.com/threads/check-for-keyboard-input.105126/