how do I change the controls in MZ?

Hello everyone, I need to change the controls of MZ, I mean, use the WASD instead of "Up arrow, Left arrow" etc. But I don´t want to buy a plugin or download it, I want to do it for code. Someone help me pls ;(
Not sure I understand - are you saying you want to make your own plugin rather than download one? You should modify the original code as it will be overwritten if you update your game's js files when a new version of MZ is available.
As Shaz says, it's always a bad idea to directly modify the source code. You should do a quick Google and see how to make a plugin that modifies a function; the function you want to modify is Input.keyMapper, which you can copy from rmmz_core.js.
Note that a plugin, for RPG Maker MV/Z, is literally just another script file (.js) that loads after the core scripts (also .js).

The general format for remapping a keyboard input in RMMV/Z is:
JavaScript:
Input.keyMapper[keyCode] = "keyName";
...where:
  • keyCode is a number (e.g. see https://keycode.info/), and
  • keyName is a string used by the game to identify the input.
I think this is the minimum plugin code for what you're asking:
JavaScript:
Input.keyMapper[87] = "up";
Input.keyMapper[65] = "left";
Input.keyMapper[83] = "down";
Input.keyMapper[68] = "right";
Note that by default the W key (code 87) is mapped to "pagedown" (Q is "pageup").
Spoiler: How to use plain code as a plugin
  1. Copy + paste the code into a text editor (e.g. Notepad).
  2. File > Save As:
    • File Type: All Files
    • Filename: whatever.js
    (This works because .js is a plaintext file format.)
  3. Import that file via the editor: Tools > Plugin Manager.
  4. Save your project to apply Plugin Manager changes.
  5. Test!

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-change-the-controls-in-mz.136305/