Assigning Number on a Keypad


I'm trying to make a keypad. I want to be able to press the number button as a game interface and for a number appear on screen to create a code.
Something kinda like this:

I'm making each button it's own object, but I currently can't figure out how to code a specific number into said object.
Anyone have any suggestions?


Kazan Games
You can add/sum strings.
if mouse_check_button_pressed(...) {
    numbers_text += "0";
Each button you press on the interface adds the string with the corresponding number. Remember: You can only add strings to strings, so don't use numbers directly without the " ".
If you want to return a usable number later, e.g. 654684, you can use real(numbers_text).

Perhaps it might be helpful later:
Last edited:


@FoxyOfJungle hit it on the head.

The only thing I would add is a controller object with global.number in the create event. Not only draw this number where you want but you can then use the same number to do things in your game through the controller object. ( Should you choose to use that number )

This means that every number you press you would have to make sure to ( += string number ) to draw.
As an example pressing the "5" you would use:

global.number += "5";
If you want to do something with a specific number/code you can always check or better use a "check/enter" key/button:

switch ( global.number ) {
"12345": // Code here //; break;
default: break;