Sometimes when making a game you may wish one key to do the same as another. For example many people use the keys WASD for movement, but then many people also use the arrow keys! So, what to do? Well, you could code the movement system twice, but that is a bit complicated and thankfully redundant as this function permits you to "map" one key to another and so any input from either key will be interpreted as the same. To do this you choose a key that you want to map (key2 - this will be the key that you write the code for) and a key that you want it to be mapped to (key1). After that, keypresses to either key will be interpreted by GameMaker Studio 2 as coming from key2. You can also use this function to design a system where the user can define their own keys for playing by simply mapping the user input key to the key that you have coded into the game.
|key1||This is the key that key1 is to be mapped to|
|key2||This is the key that is to be mapped|
The above example code will map the "A" key to the left arrow key. This means that the player can use either the "A" or the left arrow key, and that all code written for the left arrow will also respond to the "A" key being used instead.