RMMZ Is there a way to remove the existing Input.keyMapper?

Muso

Regular
Regular
Joined
Aug 27, 2022
Messages
34
Reaction score
14
First Language
Korean
Primarily Uses
RMMZ
I'm making a key setting system.
Detects the player's key input and set the code of the input key with a variable.
Input.keyMapper[$gameVariables.value] = 'up';
1.png
It works very well. But there's a problem.
Let me give you an example.

If I set [w] to 'up' and set [↑] to 'up', [↑] is not replaced by 'up' key.
[w], [↑] both become 'up' keys.

Is there a way to remove the existing Input.keyMapper?
 

TheAM-Dol

Randomly Generated User Name
Regular
Joined
Feb 26, 2022
Messages
929
Reaction score
1,624
First Language
English
Primarily Uses
RMMV
You pulled technically modify the RPG_core to alter (or remove) controls...
I am wondering why you don't use something like a keyboard config plugin and a button common event plugin :LZSskeptic:
 

Muso

Regular
Regular
Joined
Aug 27, 2022
Messages
34
Reaction score
14
First Language
Korean
Primarily Uses
RMMZ
You pulled technically modify the RPG_core to alter (or remove) controls...
I am wondering why you don't use something like a keyboard config plugin and a button common event plugin :LZSskeptic:
I already know that the keyMapper part of rmmz_core.js needs to be modified.
What I want is that every time I using a script call(Input.keyMapper[keycode] = 'name'), the keysetting is overwritten.

I am wondering why you don't use something like a keyboard config plugin and a button common event plugin :LZSskeptic: : Because I don't like UI of the keyboard config plugin. And I thought I could make it with event with a little effort.
 
Last edited:

Mac15001900

JavaScript wild sorcerer
Regular
Joined
Aug 7, 2022
Messages
252
Reaction score
317
First Language
English
Primarily Uses
RMMV
So, you'd like to clear all existing keybindings from keymapper? That's fairly simple, a for loop to iterate over existing fields would be enough.
JavaScript:
for (let field in Input.keyMapper) {
    if (!isNaN(field)) Input.keyMapper[field] = undefined;
}
The if statement is not strictly needed in vanilla, but should help if any plugins add their own fields to the keyMapper.

In case you'd just want to clear a single field, e.g. 'ok':
JavaScript:
for (let field in Input.keyMapper) {
    if (Input.keyMapper[field] === 'ok') Input.keyMapper[field] = undefined;
}
 

Muso

Regular
Regular
Joined
Aug 27, 2022
Messages
34
Reaction score
14
First Language
Korean
Primarily Uses
RMMZ
So, you'd like to clear all existing keybindings from keymapper? That's fairly simple, a for loop to iterate over existing fields would be enough.
JavaScript:
for (let field in Input.keyMapper) {
    if (!isNaN(field)) Input.keyMapper[field] = undefined;
}
The if statement is not strictly needed in vanilla, but should help if any plugins add their own fields to the keyMapper.

In case you'd just want to clear a single field, e.g. 'ok':
JavaScript:
for (let field in Input.keyMapper) {
    if (Input.keyMapper[field] === 'ok') Input.keyMapper[field] = undefined;
}
It works very well. Thank you!
 

Latest Threads

Latest Profile Posts

1920px-Toblerone_3362.jpg
My one of 50ish weaknesses...
I'm at a writer block in my game. I'm trying to think of a mini-game for one of my levels. Maybe they have to dodge boulders while climbing a hill. Give it a bad pun name like Boulder Dash?
To cater to the communitiy's needs and desires, I am now blonde ;3
So my game costs $4.99 and somebody just bought it on Itch.io and gave me a $5.00 tip as well. I'm amazed at the kindness of strangers, and grateful. Thank you, whoever you are!

Forum statistics

Threads
134,856
Messages
1,251,291
Members
177,650
Latest member
Milquetoast
Top