A professional on-screen QWERTY keyboard library for TFT displays, perfect for WiFi configuration, user input, and interactive projects.
✨ Full QWERTY Layout - Standard keyboard with 4 rows of keys
⌨️ Special Keys - Capslock, Space, Backspace, Enter, Dot, Underscore
🎨 Customizable Colors - Full color scheme customization
📱 Responsive - Works with 3-button navigation (UP/DOWN/OK)
💾 Lightweight - Minimal memory footprint
🔧 Easy Integration - Simple API, works with TFT_eSPI
- Arduino or ESP32 board
- TFT Display compatible with TFT_eSPI library
- 3 Buttons for navigation (UP, DOWN, OK)
- Open Arduino IDE
- Go to Sketch → Include Library → Manage Libraries
- Search for "OnScreenKeyboard"
- Click Install
- Download this repository as ZIP
- Open Arduino IDE
- Go to Sketch → Include Library → Add .ZIP Library
- Select the downloaded ZIP file
cd ~/Arduino/libraries
git clone https://github.com/noxustic/OnScreenKeyboard.git#include <TFT_eSPI.h>
#include <OnScreenKeyboard.h>
TFT_eSPI tft = TFT_eSPI();
OnScreenKeyboard keyboard(&tft);
#define BTN_UP 32
#define BTN_DOWN 33
#define BTN_OK 13
void setup() {
// Initialize buttons
pinMode(BTN_UP, INPUT_PULLUP);
pinMode(BTN_DOWN, INPUT_PULLUP);
pinMode(BTN_OK, INPUT_PULLUP);
// Initialize display
tft.init();
tft.setRotation(0);
// Initialize keyboard
keyboard.begin(BTN_UP, BTN_DOWN, BTN_OK);
}
void loop() {
// Get user input
String userInput = keyboard.getInput("Enter Name:", "");
// Use the input
Serial.println(userInput);
delay(3000);
}Constructor - pass your TFT_eSPI instance.
OnScreenKeyboard keyboard(&tft);Initialize the keyboard with button pins.
keyboard.begin(BTN_UP, BTN_DOWN, BTN_OK);Set the Y position where keyboard starts (default: 120).
keyboard.setKeyboardPosition(150);Set input field position and size.
keyboard.setInputFieldPosition(10, 60, 220, 35);Set maximum input length (default: 30).
keyboard.setMaxInputLength(50);void setColorScheme(uint16_t bg, uint16_t key, uint16_t key_sel, uint16_t text, uint16_t text_dim, uint16_t border, uint16_t special)
Customize all colors.
keyboard.setColorScheme(
TFT_BLACK, // Background
TFT_DARKGREY, // Key
TFT_CYAN, // Key selected
TFT_WHITE, // Text
TFT_LIGHTGREY, // Text dim
TFT_BLUE, // Border
TFT_YELLOW // Special keys
);Display keyboard and get user input (blocking).
String name = keyboard.getInput("Enter Name:", "");
String email = keyboard.getInput("Email:", "user@example.com");Manually draw the keyboard.
keyboard.draw();Clear the keyboard area.
keyboard.clear();Set the current input text.
keyboard.setText("Hello");Get the current input text.
String current = keyboard.getText();Clear the current input.
keyboard.clearText();Toggle capslock state.
keyboard.toggleCapslock();Check if capslock is active.
if (keyboard.isCapslock()) {
// Capslock is on
}Get currently selected key index.
int selected = keyboard.getSelectedKey();Set the selected key.
keyboard.setSelectedKey(10); // Select 'q' keyRow 1: [ 1 ][ 2 ][ 3 ][ 4 ][ 5 ][ 6 ][ 7 ][ 8 ][ 9 ][ 0 ]
Row 2: [ q ][ w ][ e ][ r ][ t ][ y ][ u ][ i ][ o ][ p ]
Row 3: [ a ][ s ][ d ][ f ][ g ][ h ][ j ][ k ][ l ]
Row 4: [ z ][ x ][ c ][ v ][ b ][ n ][ m ][ CAPS ]
Row 5: [ . ][ SPACE ][ DEL ][ _ ]
Row 6: [ DONE ]
| Key | Code | Function |
|---|---|---|
| SPACE | 32 | Insert space |
| BACKSPACE | 8 | Delete last character |
| ENTER | 13 | Confirm input (returns text) |
| CAPSLOCK | 20 | Toggle uppercase |
| DOT | '.' | Insert period |
| UNDERSCORE | '_' | Insert underscore |
String name = keyboard.getInput("Enter Name:", "");
Serial.println("Hello, " + name + "!");String ssid = keyboard.getInput("WiFi SSID:", "");
String pass = keyboard.getInput("Password:", "");
WiFi.begin(ssid.c_str(), pass.c_str());// Dark theme
keyboard.setColorScheme(
0x0000, // Black background
0x2104, // Dark gray keys
0x07FF, // Cyan selection
0xFFFF, // White text
0x8410, // Gray dim text
0x4208, // Dark border
0xFBE0 // Orange special keys
);
String input = keyboard.getInput("Dark Theme:", "");struct UserData {
String name;
String email;
String phone;
};
UserData user;
user.name = keyboard.getInput("Name:", "");
user.email = keyboard.getInput("Email:", "");
user.phone = keyboard.getInput("Phone:", "");Default button configuration (customizable):
#define BTN_UP 32 // Navigate up
#define BTN_DOWN 33 // Navigate down
#define BTN_OK 13 // Select keyConnect buttons with internal pull-ups:
Button → GND
Pin → INTERNAL_PULLUP
The library uses TFT_eSPI. Configure your display in:
- Arduino:
User_Setup.hin TFT_eSPI library folder - PlatformIO:
platformio.inibuild flags
Example for ST7789 240x320:
#define ST7789_DRIVER
#define TFT_WIDTH 240
#define TFT_HEIGHT 320Approximate memory usage:
- Flash: ~8KB
- RAM: ~2KB (includes key layout and text buffer)
✅ ESP32 (all variants)
✅ ESP8266
✅ Arduino Mega 2560
✅ Arduino Due
✅ ST7789 (240x320, 240x240)
- Check TFT_eSPI is properly configured
- Verify display dimensions match code
- Ensure
tft.init()is called beforekeyboard.begin()
- Verify pin numbers in
begin() - Check buttons are connected to GND
- Ensure
pinMode(pin, INPUT_PULLUP)is set
- Use
setMaxInputLength()to limit length - Default is 30 characters
- Display scrolls automatically for longer text
- Use
setColorScheme()to customize - Ensure 16-bit color format (RGB565)
- Convert colors:
tft.color565(r, g, b)
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - see LICENSE file for details.
Created by NOXUSTIC for embedded systems and IoT projects.
Designed for easy WiFi configuration and user input in Arduino and ESP32 projects.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@noxustic.com
- Initial release
- QWERTY layout with 4 rows
- Special keys support
- Color customization
- TFT_eSPI integration
- Example sketches
Future features under consideration:
- Numeric-only keyboard mode
- Symbol/special character layout
- Multi-language support
- Touch screen support
- Password masking option
- Auto-complete suggestions
- Sound feedback
- TFT_eSPI - TFT display library
Made with ❤️ by NOXUSTIC