Reply Keyboard
Custom reply keyboard markup with contact, location, poll request buttons, and input placeholder support.
Basic Usage
Simple reply keyboard
from pykeyboard import ReplyKeyboard
kb = ReplyKeyboard(
row_width=2,
resize_keyboard=True,
one_time_keyboard=True,
placeholder="Choose an option...",
)
kb.add("✅ Yes", "❌ No", "🤷 Maybe")
await message.reply("What do you think?", reply_markup=kb)Constructor
| Parameter | Type | Default | Description |
|---|---|---|---|
row_width | int | 3 | Max buttons per row (1–8) |
resize_keyboard | bool | None | Resize to fit content vertically |
one_time_keyboard | bool | None | Disappear after first use |
is_persistent | bool | None | Keep visible between messages |
selective | bool | None | Show only to specific users |
placeholder | str | None | Placeholder text in input field |
Button Types
Use ReplyButton for advanced button types beyond plain text.
| Parameter | Type | Description |
|---|---|---|
text | str | Button label (required) |
request_contact | bool | Request phone contact |
request_location | bool | Request GPS location |
request_poll | KeyboardButtonPollType | Request a poll |
web_app | WebAppInfo | Open a Web App |
request_users | KeyboardButtonRequestUsers | Request user selection |
request_chat | KeyboardButtonRequestChat | Request chat selection |
Special button types
from pykeyboard import ReplyKeyboard, ReplyButton
kb = ReplyKeyboard(resize_keyboard=True)
kb.add(
ReplyButton(text="📱 Share Contact", request_contact=True),
ReplyButton(text="📍 Share Location", request_location=True),
)Removing the Keyboard
from pykeyboard import PyReplyKeyboardRemove, PyForceReply
# Remove the keyboard
await message.reply("Keyboard removed", reply_markup=PyReplyKeyboardRemove())
# Force reply with placeholder
await message.reply(
"Please type your answer:",
reply_markup=PyForceReply(placeholder="Type here...")
)