Skip to content

Keyboards

In the telegram system there are two types of keyboards:

Reply Inline
Reply keyboard Inline keyboard
Keyboard for each user in the chat Keyboard linked to the certain message

Low-level way to create keyboard looks like in the next snippet:

ReplyKeyboardMarkup(
    matrix {
        row {
            add(SimpleKeyboardButton("Simple text"))
            // ...
        }
        // ...
    }
)

In case you wish to create inline keyboard, it will look like the same as for reply keyboard. But there is another way. The next snippet will create the same keyboard as on the screenshots above:

// reply keyboard
replyKeyboard {
    row {
        simpleButton("7")
        simpleButton("8")
        simpleButton("9")
        simpleButton("*")
    }
    row {
        simpleButton("4")
        simpleButton("5")
        simpleButton("6")
        simpleButton("/")
    }
    row {
        simpleButton("1")
        simpleButton("2")
        simpleButton("3")
        simpleButton("-")
    }
    row {
        simpleButton("0")
        simpleButton(".")
        simpleButton("=")
        simpleButton("+")
    }
}

// inline keyboard
inlineKeyboard {
    row {
        dataButton("Get random music", "random")
    }
    row {
        urlButton("Send music to friends", "https://some.link")
    }
}