pKeyboard guide

The full reference. For an overview, see the README. A customizable, lightweight virtual keyboard for Android. It has zero library dependencies and uses only the Android framework and the Kotlin stdlib.

Building

Open the folder in Android Studio and run app. For release signing, put a keystore.properties file in the project root (storeFile, storePassword, keyAlias, keyPassword). Without it, the release build is unsigned and the build no longer fails.

Use JDK 17 or 21 for command-line builds. Run ./gradlew :app:verifyDictionaryImport for dependency-free dictionary format checks using synthetic data. Run ./gradlew :app:verifyWordIndex to check suggestion ranking against a reference implementation and benchmark 200,000 generated words.

Run ./gradlew :app:validateLayouts (Windows: tools/validate-layouts.ps1) to validate shipped layouts. Use -PlayoutDir=<directory> or the script -LayoutDir argument for a custom folder. Checks cover parser warnings, balanced structure, row/key shape, finite positive dimensions, actions, popup limits and missing layout references. The command exits unsuccessfully on errors and never rewrites files.

With an authorized Android device connected, tools/device-checks.ps1 all runs the existing framework-only integration cases. It installs debug app/test APKs and restores settings/learned words after each case. Hardware hotplug and live microphone capture require separate manual testing; automated checks cover hardware policy and provider discovery/routing.

./gradlew :app:verifyKeyboardLogic runs independent JVM checks for compose/dead-key state, generated rows, modifier maps, Unicode validation, emoji extraction and randomized layout serialization round-trips. The standard :app:check task includes these checks, dictionary/index checks and layout validation. Device cases learning and async cover privacy/persistence and deterministic cancellation of stale suggestion work; all includes both. Android installs the temporary x.vladgba.keyboard.debug.test instrumentation package, which normally has no Home-screen icon and can trigger a vendor installer notice. It is removed after the testing session.

Versioning

The version lives in version.properties (major, minor, patch, semantic versioning):

Bump it with ./gradlew bumpPatch (fixes), bumpMinor (new features) or bumpMajor (breaking changes, e.g. file formats); ./gradlew printVersion shows the current one.

Style inheritance chain: Key → Row → Layout → Theme → settings.txt → built-in defaults.

Settings (in settings.txt)

KeyDefaultMeaning
metaOneShot1Modifier keys: tap once for the next key only, tap again to lock, tap a third time to release. 0 restores the old on/off toggle.
textExpansion1Expands abbreviations from the Dictionary (Settings → Dictionary) when you type a space, Enter or punctuation.
autoNumLayout1Switches to the 123 layout in number, phone and date fields.
landscapeHeight1Keyboard height multiplier in landscape, e.g. 0.75.
bottomPadding0Bottom margin in dp elevating the keyboard from the gesture navigation bar.
joyAcceleration100Joystick keys ("mode": "joy", e.g. the space bar cursor slider): fast drags need less distance per step, in %; 0 turns it off. Sideways drags never jump lines, and with Ctrl held steps need twice the distance.
selectionSlider1With Shift on or text selected, dragging the space bar grows or shrinks the selection (see below). 0 turns it off.
circleGestures1Circle and roundtrip gestures on keys (see below). 0 turns them off.
edgeGestureGuard1Android 10+ gesture navigation: swipes that start at the screen edge over the keyboard go to the keyboard instead of Back (the system honours up to 200dp of keyboard height). 0 turns it off.
clipHistory1Remember copied text (clipboard history, opened with @CLIPBOARD). 0 turns it off.
clipExpiry15Minutes unpinned clips are kept; 0 = never expire. Pinned clips stay until removed.
numberRow0Adds a row of digits on top of typing layouts that don't have one: 0 off, 1 digits, 2 digits with ! @ # $ % ^ & * ( ) on swipe-up. A layout can set its own "numberRow" (e.g. "0") to override it. The layout files are not changed.
split1Split keyboard: 0 off, 1 on wide screens (keyboard at least 600dp wide: unfolded foldables, tablets, phones in landscape), 2 always. Each row splits at the key boundary nearest the middle; a wide key across the middle (the space bar) is stretched over the gap.
splitGap25Width of the empty middle of a split keyboard, in % of its width.
learnWords1Learn words as they are typed, for suggestions (never in password fields or where the app asks not to). Learned words are in learned.words (word<TAB>count), part of backups.
suggestions1Word suggestion bar above the keys in text fields (not in password, number or "no suggestions" fields): completes the word being typed from learned words, best in the middle; tap one (or use @COMPLETE_1/_2/_3, @COMPLETE_EMOJI, 1 = best) to replace the word and add a space.
spaceAccept0Space replaces a typed word that isn't a learned word with the top suggestion (completion or one-edit typo correction); Backspace right after restores the typed word.
emojiSuggestions1Suggest an emoji for the typed word from imported keywords (Learned words → Import emoji keywords: Unicode CLDR annotations .xml/.json, or keyword<TAB>emoji lines; kept in emoji.keywords). Tapping it (or @COMPLETE_EMOJI) adds the emoji after the word.
smartPunctuation1Cleans space before punctuation: typing punctuation (. , ! ? : ;) after a space removes the space.
appLayouts()Default layout per app package, e.g. ("com.termux": "code").
errorToasts1Shows errors as toasts. With 0, errors are only logged.

New features & options:

Layout format (Flexaml)

tabbedEmoji=1 opens a recycled, scrollable grid with tabs for the nine existing emoji categories. It includes related variants from the emoji pages and keeps multi-code-point sequences intact. The current typing layout stays selected; use the back arrow to return, or Backspace to delete. The last category is remembered only while the keyboard lives. Off by default in Settings; disabling it restores the existing emoji layouts. No emoji history is stored, and existing custom emoji pages are read without being rewritten.

visualControls=1 enables Settings sliders for borderWidth (0–6 dp), keyboardOpacity (35–100%) and keyOpacity (0–100%). The master switch is off by default and restores theme-defined borders/opacity when disabled; key-fill transparency does not fade labels. Whole-keyboard opacity includes suggestions and popups.

Settings → Voice includes a recognition-provider picker. customVoiceProvider=1 uses the chosen installed service (voiceProvider stores its component); disabled by default. System default, a removed service or a service that cannot be created falls back to the existing system/on-device recognition path. Choosing a provider never grants microphone permission or starts listening by itself.

hideWithPhysicalKeyboard=1 hides the software keyboard when a non-virtual alphabetic keyboard connects and restores a keyboard hidden for that reason on disconnect. Off by default, in Settings → Hardware. DPAD remotes, touchscreens and virtual devices do not trigger it.

Enable Expanded language layouts in Settings to make the additional Arabic, Hebrew, Greek, Turkish, Italian, Portuguese, Czech, Hungarian, Swedish, Finnish, Norwegian and Danish layouts available in Built-in layouts. Add only the ones you want; existing files are preserved. The feature is off by default and disabling it removes these layouts from normal cycling/selection. See layout sources for provenance and mobile adaptations.

orientationLayouts=1 remembers manual typing-layout choices separately in portrait and landscape (portraitLayout, landscapeLayout). Enable it in Settings; it is off by default. App-specific layouts take priority, and temporary number/emoji pages do not replace the remembered choice.

sideNumpad: 0 off (default), 1 right, 2 left, 3 right in landscape only. numpadWidth sets its width (15–45%, default 25%). invertNumpad=1 swaps 1–3 and 7–9 on the side and standalone pads. These settings never rewrite layout files.

extraKeysRow=1 adds a toolbar to typing layouts. Configure up to 16 pipe-separated extraRowKeys in Settings: navigation names, Ctrl/Alt/Shift/Meta, F1–F12, or literal text. Default: Esc|Tab|Ctrl|Alt|←|↓|↑|→. Off by default.

rtlMarks=1 adds Unicode direction controls (LRM/RLM/ALM and LRI/RLI/FSI/PDI), also available as @RTL:<name> actions. mirrorBrackets=1 swaps single typed bracket/angle-quote pairs on layouts marked rtl=1 or containing RTL letters. Both options are off by default and configurable in Settings.

combiningMarks=1 adds Arabic vowel marks or Hebrew niqqud on matching layouts. Keys insert the combining character after the base letter; custom layouts can use @MARK:<hex codepoint>. Off by default. Word learning, completion-prefix detection and word deletion keep diacritics attached to their word.

modifierMappings=1 enables layout-defined modmap tables (off by default). On a key: "modmap": ("alt": "α", "ctrl+shift": "macro:name"). At layout level: "modmap": ("alt": ("a": "α", "b": "β")). Key mappings override layout mappings. Names: shift, ctrl, alt, altgr, meta, or none. Values use normal action syntax (text, negative key code, combo, macro or layout action). Source modifiers are consumed; specify output modifiers explicitly in a combo.

(                                   # layout
    (                               # row
        ("key": "q", "", "", "", "", "", "", "1"),   # label + 8 popup chars (positions 0..7)
        ("key": "←", "code": "-67", "holdRepeat": "1", "width": "2")
    )
)

code: a negative value is an Android KeyEvent keycode. mode: popup / joy / meta / random. layout: @NEXT, @PREV, @NUM, @TEXT, @EMOJI or a layout name. Other options: hold, hard, text, textCurOffset, clipboard, record, action, @VOICE, @COMPOSE, @DELETE_WORD, @DELETE_WORD_FORWARD, @CLIPBOARD, @DEAD:<name>, @COMPLETE_1/_2/_3, @tr_voice/<src>-<dst> (e.g. @tr_voice/ru-en for voice translation), sound*, vib*, and the style keys listed in core/Constants.kt.

Popup slots accept negative decimal keycodes ("-61" sends Tab), combinations ("shift+-61" sends Shift+Tab), and the same special actions as hold/heavy press. Surrounding whitespace is ignored for actions and keycodes, and a Unicode minus (−61, as some keyboards type it) counts as -; a slot like (key: "-61") is also a keycode; ordinary text keeps its whitespace, and positive digits remain literal characters.

A popup position can also be a settings node, using the same parentheses/array syntax as a main key:

("key": "a",
    ("key": "Tab", "code": "-61"),
    ("key": "⇤", "code": "-61", "meta": "1"),
    ("text": "-61"),
    ("key": "Copy", "combo": "ctrl+c")
)

Supported popup settings:

If multiple actions are present, precedence is macro, combo, layout, text, code, then key. Popup actions do not inherit the main key's action settings. Nested popup positions and other main-key settings are rejected by validation. Existing string slots retain their behavior.

In the layout editor, tap a popup position and choose Action, Key code (type -61, 61 or tab, or pick from the list; always stored as (code: "-61")), Literal text (typed exactly, so -61 inserts those characters), or Key settings. Key settings retain the full node when reopened and show an error instead of saving invalid input.