Keyboard objects

ReplyKeyboardMarkup

class ReplyKeyboardMarkup(*, keyboard, resize_keyboard=None, one_time_keyboard=None, selective=None)

This class represents a custom keyboard with reply options

Parameters
  • keyboard (list of list of KeyboardButton) – List of button rows, each represented by an list of KeyboardButton objects

  • resize_keyboard (bool) – Optional: Requests clients to resize the keyboard vertically for optimal fit. Defaults to false, in which case the custom keyboard is always of the same height as the apps’s standard keyboard

  • one_time_keyboard (bool) – Optional: Requests client to hide the keyboard as soon as it’s been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat - the user can press a special button in the input field to see the custom keyboard again

  • selective (bool) – Optional: Use this parameter if you want to show the keyboard to specific users only

ReplyKeyboardRemove

class ReplyKeyboardRemove(*, remove_keyboard, selective=None)

Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard

Parameters
  • remove_keyboard (bool) – Requests clients to remove the custom keyboard

  • selective (bool) – Optional: Use this parameter if you want to remove the keyboard for specific users only

KeyboardButton

class KeyboardButton(*, text, request_contact=None, request_location=None)

This class represents one button of the reply keyboard

Parameters
  • text (str) – Text of the button. If none of the optional fields are used, it will be sent as a message, when the button is pressed

  • request_contact (bool) – Optional: If True, the user’s phone number will be sent as a contact when the button is pressed. Available in private chats only

  • request_location (bool) – Optional: If True, the user’s current location will be sent when the button is pressed. Available in private chats only