Here is just a quick snippet of code that took me a while to do so I thought it might help someone else.
I needed some code that did rebindable controls like you see in many AAA games.
This code is just an array of the standard buttons on a QWERTY keyboard with the array key being its ASCII code and the array value being a human readable name for that button. In GameMaker when dealing with keyboard commands it gives each key a number, the number is the same as its ASCII value.
key[9] = 'Tab' key[8] = 'Backspace' key[160] = 'Left Shift' key[162] = 'Left Control' key[164] = 'Left Alt' key[165] = 'Right Alt' key[92] = 'Right Windows Key' key[163] = 'Right Control' key[161] = 'Right Shift' key[12] = 'Num 5' // This is actual Num 5 but when Numlock is off, even Wiki says it "Does Nothing" key[13] = 'Enter' key[16] = 'Shift' key[17] = 'Control' key[18] = 'Alt' key[19] = 'Pause' key[20] = 'Capslock' key[32] = 'Space' key[33] = 'Page up' key[34] = 'Page down' key[35] = 'End' key[36] = 'Home' // key[27] = 'Escape' // cant be used because its used to exit this menu key[37] = 'Left' key[38] = 'Up' key[39] = 'Right' key[40] = 'Down' key[45] = 'Insert' key[46] = 'Delete' key[48] = '0' key[49] = '1' key[50] = '2' key[51] = '3' key[52] = '4' key[53] = '5' key[54] = '6' key[55] = '7' key[56] = '8' key[57] = '9' key[65] = 'A' key[66] = 'B' key[67] = 'C' key[68] = 'D' key[69] = 'E' key[70] = 'F' key[71] = 'G' key[72] = 'H' key[73] = 'I' key[74] = 'J' key[75] = 'K' key[76] = 'L' key[77] = 'M' key[78] = 'N' key[79] = 'O' key[80] = 'P' key[81] = 'Q' key[82] = 'R' key[83] = 'S' key[84] = 'T' key[85] = 'U' key[86] = 'V' key[87] = 'W' key[88] = 'X' key[89] = 'Y' key[90] = 'Z' key[91] = 'Windows Key' key[93] = 'Context Menu' key[96] = 'Num 0' key[97] = 'Num 1' key[98] = 'Num 2' key[99] = 'Num 3' key[100] = 'Num 4' key[101] = 'Num 5' key[102] = 'Num 6' key[103] = 'Num 7' key[104] = 'Num 8' key[105] = 'Num 9' key[106] = 'Num *' key[107] = 'Num +' key[109] = 'Num -' key[110] = 'Num .' key[111] = 'Num /' key[112] = 'F1' key[113] = 'F2' key[114] = 'F3' key[115] = 'F4' // was left black key[116] = 'F5' // was left black key[117] = 'F6' // was left black key[118] = 'F7' key[119] = 'F8' key[120] = 'F9' // was left black key[121] = 'F10' key[122] = 'F11' key[123] = 'F12' // was left black key[144] = 'NUMLOCK' key[173] = 'Mute' key[173] = 'Volume Down' key[173] = 'Volume Up' key[186] = ';' key[187] = '=' key[188] = ',' key[189] = '-' key[190] = '.' key[191] = '/' key[192] = "'" // actually ` key[219] = '[' key[220] = '\' key[221] = ']' key[222] = "\#" // actually # but that needs to be escaped key[223] = "`" // actually ` but that needs to be escaped
And in case you wondered this is how I did the rebindable part:
changeinput = 0 // if this = 1 the player wants to select a new button for this command valuep1 = vk_space // this should be loaded from a save file is the keypress code STEP EVENT: if (clicked()) { changeinput = 1 // checking to see if the player wants to change this key } if (keyboard_check_pressed(vk_anykey)) { if (keyboard_check_pressed(vk_escape)) { changeinput = 0 } else { if (changeinput == 1) { valuep1 = keyboard_key // This where the player selects the new key they want to rebind changeinput = 0 } } } if (changeinput < 0) { changeinput = 0 } DRAW EVENT: if (changeinput == 0) { draw_set_colour(c_gray) draw_text(x,y,key[valuep1]) } else { draw_set_colour(c_black) draw_text(x,y,'Press Key') }