keyMapper and onclick help

I would like to start by saying I am not only new to javascript but also RPG Maker so I am still learning everything. (purchased during the summer sale)

I am using RPG Maker MV and I was hoping to change some default settings. The first thing I wanted to do was make WASD the default movement which I did using the following code referencing the rpg_core.js file.
Code:
(function(){
    Input.keyMapper[65] = 'left';     //a
    Input.keyMapper[68] = 'right';    //d
    Input.keyMapper[87] = 'up';       //w
    Input.keyMapper[83] = 'down';   //s
})();

That seems to work fine as a plugin for starters but there are a couple of other things I'm not sure how to accomplish. The left click by default is also a movement command which I would like to remove. How do I go about rebinding the mouse buttons? I know of the onclick event but I'm not sure if that is the way I would do this. Additionally, how would I differentiate between input.keyMapper for in game and for the main menu if I wanted things to be different? I understand this could possibly be extensive so if anyone would be willing to at least point me in the right direction that would be great. Thank you.
Hi there, and welcome to the forums!

The left click by default is also a movement command which I would like to remove.

There's a suggestion in this thread, that I think will work for you.

How do I go about rebinding the mouse buttons? I know of the onclick event but I'm not sure if that is the way I would do this.

The onclick event is to "listen" for a mouse click and record where it happens, it's a Javascript method to attach to HTML elements. In the case of RPG Maker MV, the entire game is just one element, so there needs to be follow-on logic to determine what to do when the mouse is clicked. There's a wrapper class called TouchInput which interprets the onClick event into more friendly terms for game logic.
I don't understand what you mean by "rebinding" the mouse buttons though - do you mean you have some more buttons on your mouse that you want the game to recognize? Or you want the left-click and right-click to do different things than they are now?

Additionally, how would I differentiate between input.keyMapper for in game and for the main menu if I wanted things to be different?

You would need to do this:
1. When the menu opens, make a copy of the current input keyMapper
2. Clear the keyMapper and add whatever inputs you'd like
3. When the menu closes, restore the copy of the Input keyMapper

For an example of this, you can study my Notepad plugin (link in my signature)
Hello, thank you for all of the helpful information and welcoming me to the forum.

I don't understand what you mean by "rebinding" the mouse buttons though - do you mean you have some more buttons on your mouse that you want the game to recognize? Or you want the left-click and right-click to do different things than they are now?
I guess rebinding was a bad term to use but I'll try and explain what I mean. So right now when I start the game up left click acts as player movement. I click on the area and the player/party moves there. I would like to remove that and make left click do something differently. For instance I would like left click to act as an action button I guess. So while opening an in game menu or dialogue you use left click for selections only. Subject to change in the future at my own discretion etc. I understand using "keyMapping" for the keyboard keys so I am just trying to figure out how to do something similar with my left and right click on the mouse.

Thanks for the help.

EDIT: Also I posted before reading the thread and plugin you referenced to me which I now realize was a mistake considering they answer most of my questions and concerns! I appreciate it Aloe Guvner
Conceptually, we start with the Input and TouchInput classes. These have functions that are "listening" to the browser (either the built-in browser or an actual web browser like Firefox) to learn if you pressed a key or clicked the mouse.

Then you have scenes, like Scene_Map or Scene_Title. The scenes update every frame (60 frames per second). To actually do something based on the input, somewhere in that update cycle you would check the Input and/or TouchInput classes for your input, and then do your stuff if the input is triggered.

For example: Every frame, the map scene checks if the "ok" button is pressed. This is abstracted by the Input class, which assigns "ok" to several different keys (like Enter, Z, etc.). If the "ok" button is pressed, then it "does stuff" - like checking if there's an event in front of the player and executing the event.

TouchInput is the same idea, but it also has a location associated with it (x, y). So in the scene, it checks if the touch happened and if the location that was touched should "do something".

Note: The update part of the scene also runs for all of its children every frame - the children are usually windows and sprites

Original thread: https://forums.rpgmakerweb.com/threads/keymapper-and-onclick-help.96950/