On this page
Everyone has typed a reply, stared at it and wished it sounded nicer, funnier or just shorter. This brief puts that fix inside the keyboard itself: type as normal, tap a tone, and get a rewrite you can drop into any chat app. Android is the natural home for it, because InputMethodService lets a real app become your system keyboard with its own layout, suggestion row and themes. An iPhone keyboard extension is possible too, but it needs Allow Full Access for any network call and a Mac with Xcode to build. The first proof: a typed sentence is rewritten in the polite tone and inserted into a messaging app, and nothing is sent until the user taps the tone.
Screens
- Keyboard: A QWERTY layout with shift, numbers, emoji key, backspace repeat and a tone row above the keys.
- Tone row: Polite, funny and short chips that rewrite the current text or draft a reply, with undo.
- Clipboard: Recent copied snippets the user chose to keep, with pin and clear all.
- Setup: Step-by-step screens to enable the keyboard in system settings and switch to it.
- Themes and privacy: Light, dark and accent colours, key sound and vibration, and a switch that turns AI off completely.
Data model
| Table | Key fields | Purpose |
|---|---|---|
| keyboard_settings | theme (text), accent (text), key_sound (bool), haptics (bool), ai_enabled (bool) | Preferences in DataStore, read quickly every time the keyboard opens. |
| clip_items | id (uuid), text (text), pinned (bool), created_at (timestamptz) | Clipboard history saved only on the device, with automatic expiry for unpinned items. |
| rewrite_requests | id (uuid), tone (text), char_count (int), status (text), created_at (timestamptz) | A local log of rewrite attempts without the text itself, for retry and error display. |
A keyboard sees everything a person types, including passwords and private messages, so the default is that nothing leaves the phone. Text goes out only when the user taps a tone chip, and only the current field's text. That request goes to a backend function in your own Supabase (an Edge Function, for example), which holds your AI provider key and forwards the text; the key never ships inside the app. The function should require a signed-in user or a per-install token, rate-limit calls and avoid storing message text. Password and number-only fields must hide the tone row entirely.
Native features
This is one of the clearest cases where a native app does something a website cannot. The keyboard runs as a system service in every app, reads the field type through EditorInfo, and writes text through InputConnection. The AI part is just one network call; the hard, valuable work is a fast, dependable keyboard that people trust with their typing.
| Feature | Android (Kotlin) | iPhone (SwiftUI) | Notes |
|---|---|---|---|
| System keyboard | InputMethodService with a Compose or View-based input view | Custom keyboard extension using UIInputViewController | On iPhone, network access requires the user to grant Allow Full Access. |
| Inserting text | currentInputConnection.commitText and deleteSurroundingText | textDocumentProxy.insertText and deleteBackward | Replace only the text the user selected or the current field, and offer one-tap undo. |
| Sensitive fields | EditorInfo inputType password and visible-password checks | Secure text entry fields use the system keyboard automatically | Never show the AI row or save clipboard items for password fields. |
| AI rewrite call | OkHttp or Ktor call to your own backend function | URLSession call to the same function | Time out after a few seconds and keep the original text if anything fails. |
Android notes (Kotlin and Jetpack Compose)
Declare the service with the BIND_INPUT_METHOD permission and an input-method XML file, then return the keyboard view from onCreateInputView. Compose can render the keys inside the IME window if the service supplies a lifecycle owner; otherwise a custom View stays lighter. Key presses must feel instant, so keep layout math off any network path.
- In onStartInputView, read EditorInfo.inputType and imeOptions to choose the layout, hide the tone row in password fields and set the action key label to send, search or next as the host app asks.
- Run the rewrite call in a coroutine scoped to the service, show a small spinner on the chosen chip, and when the reply returns replace the field text through one InputConnection batch edit so a single undo restores the original.
- Test on a real Android phone in at least three apps, such as a messenger, a browser address bar and a password field. Turn on airplane mode and tap Polite: the keyboard must keep typing normally and show a short offline message.
iPhone notes (Swift and SwiftUI)
On iPhone the keyboard is an app extension with tight memory limits, hosted inside a container app that explains setup. SwiftUI views can be embedded in UIInputViewController through a hosting controller, and settings can be shared with the container app through an App Group.
- Request network access with RequestsOpenAccess in the extension's Info.plist, and check hasFullAccess at runtime. Without it, hide the tone row and explain in the container app why the permission is needed and what text is sent.
- Keep the extension light: no large models or image assets, and release memory on viewWillDisappear. Always include the globe key via needsInputModeSwitchKey so people can switch back to the system keyboard.
- Run it on a physical iPhone, because keyboard extensions behave differently in the Simulator. Type in Messages and Notes, deny Full Access, and confirm normal typing still works with the AI row hidden.
Copy-paste prompt
I keep sending dry texts and then regretting them. Build me an AI keyboard for Android that I can use in any app. Make a real system keyboard with QWERTY, numbers, emoji, backspace repeat and a setup screen that walks me through enabling it. Above the keys, add a tone row with Polite, Funny and Short: tapping one rewrites what I typed, or drafts a reply, and I can undo it in one tap. Send text only when I tap a tone, and only the current field. The AI call must go through a backend function in my own Supabase that keeps my API key; never put a key inside the app. Hide the tone row in password fields and when I turn AI off. Add a clipboard tray that stays on the phone, plus light, dark and accent themes, key sound and vibration. Handle offline, slow replies and errors by keeping my original text. Acceptance: type a sentence in a chat app, tap Polite, see the rewrite inserted, undo it, and confirm a password field never shows the tone row.
Opens Apirex with this prompt in the box. Pick the Android · Kotlin tab before you send.
Acceptance test
- Enable the keyboard from the setup screen on a real phone and switch to it inside a messaging app.
- Type a blunt sentence, tap Polite and confirm the rewrite replaces only that field's text; tap undo and get the original back exactly.
- Open a password field and confirm the tone row and clipboard tray are hidden and nothing typed there is saved.
- Turn on airplane mode, tap Funny and confirm a short offline message while normal typing keeps working.
- Check your backend function logs: one request per tap, no API key in the app package, and no stored message text.
Look closely at speed and trust. Key taps should never wait on the network, and a slow AI reply should not freeze the keys or insert text after the user has moved to a different field. Switch to another app while a rewrite is loading and confirm the late reply is dropped instead of typed into the wrong conversation. Turning AI off in settings should stop every call immediately, not after the next restart.
Frequently asked questions
Can the keyboard read what I type in other apps?
A keyboard receives keystrokes by design, which is why this brief keeps everything local and sends text only on a tone tap. Password fields never reach the AI row, and you can turn AI off completely.
Why does the AI call need my own backend?
An API key inside an app can be extracted from the package. A backend function in your own Supabase holds the key, checks who is calling, limits abuse and lets you switch AI providers without shipping an update.
Will it work on iPhone the same way?
Mostly. iPhone keyboard extensions need Allow Full Access for network calls, have tighter memory limits and cannot be used in secure fields. Building the iPhone version also needs a Mac with Xcode.
Build this blueprint
The blueprint prompt, ready for your platform. Edit anything before you send it.
Opens Apirex with this prompt. Pick the Android · Kotlin tab before you send. The Free plan includes 5 Rex Credits a day.