Configuration

Word prediction

Enabled by default. Disable it globally on the component or at runtime via the singleton:

VirtualKeyboard { predictionEnabled: false }

// or at runtime:
Lnvk.predictionEnabled = false

To keep prediction off for some languages only, leave the global switch on and set predictionEnabled: false on those input profiles (see Languages). A profile can also turn off next-word suggestions alone with nextWordEnabled: false.

Suggestions follow what you type: a capital first letter capitalises the suggestion, and caps lock writes it in capitals. Words that always take a capital, such as German nouns or the English I, keep it.

Accents are optional when typing: ecole suggests école and uber suggests über.

Prediction is automatically disabled for fields with Qt.ImhNoPredictiveText, Qt.ImhSensitiveData, Qt.ImhHiddenText, or any numeric, dial, date, or time hint. Read-only properties Lnvk.effectivePredictionEnabled and Lnvk.imeInteractionEnabled reflect the active hint mask (see Input method hints).

Custom prediction dictionaries

Provide domain-specific prediction dictionaries (medical, legal, product names, etc.) per language.

Step 1: Build a .pred file

Use the packaged compiler from your Katakata bundle:

# From package root
./bin/lndict-compiler --flat --lang en my-words.txt prediction-en-custom.pred

--lang names the dictionary's language, so its words are capitalised and matched by that language's rules. Always set it; it is essential for Turkish, Azerbaijani and Romanian.

Input formats accepted by --flat:

  • Word list (one word per line): word
  • Word + frequency: word<TAB>frequency
  • Full prediction TSV: word<TAB>display<TAB>frequency, where word is the lowercase lookup key and display the suggested form (haus<TAB>Haus<TAB>900)

Word-list rows automatically get a high default frequency so custom entries rank near the top. Matching ignores case, and words are suggested as written: Paris is suggested when typing par.

Step 2: Register custom dictionaries in your app

Register one dictionary per language/tag.

From QML (via the Lnvk singleton):

import Ln.VirtualKeyboard 1.0

Component.onCompleted: {
    Lnvk.setCustomPredictionDictionary("en", "/opt/mydicts/prediction-en-custom.pred")
    Lnvk.setCustomPredictionDictionary("en-US", "/opt/mydicts/prediction-en-us-custom.pred")
}

From C++:

#include <lnvk>

auto *kb = lnvk::qt::KeyboardManager::instance();
kb->setCustomPredictionDictionary("en", "/opt/mydicts/prediction-en-custom.pred");
kb->setCustomPredictionDictionary("en-US", "/opt/mydicts/prediction-en-us-custom.pred");

Both paths refer to the same singleton instance; calls made from C++ are visible from QML and vice versa.

Language resolution order:

  1. exact BCP47 tag (for example en-US)
  2. primary tag fallback (for example en)

Step 3: Choose merge mode

VirtualKeyboard {
    customPredictionMode: Lnvk.Supersede
}

// or on the singleton:
Lnvk.customPredictionMode = Lnvk.Supersede

From C++:

auto *kb = lnvk::qt::KeyboardManager::instance();
kb->setCustomPredictionMode(lnvk::qt::KeyboardManager::Supersede);

Modes:

  • Disabled: ignore custom dictionaries; use built-in only
  • Replace: use custom dictionary only for matching language/tag (fallback to built-in if missing/invalid)
  • Supersede: custom candidates first, then built-in candidates

Clear mappings at runtime:

Lnvk.clearCustomPredictionDictionary("en-US")
Lnvk.clearCustomPredictionDictionaries()
kb->clearCustomPredictionDictionary("en-US");
kb->clearCustomPredictionDictionaries();

Number row

Show a persistent row of digit keys above the letter row:

VirtualKeyboard { numberRowEnabled: true }

Lnvk.numberRowEnabled = true

Learning data & privacy

The keyboard learns from user input to improve predictions and IME candidate ranking. By default, learned (input, word) pairs are persisted locally in plaintext (not encrypted).

Privacy: all learning is on-device. No data leaves the device: there is no telemetry and no network transmission.

What is stored

Each time the user picks a suggestion or candidate, the keyboard records what was typed and the word chosen, and ranks that word higher the next time the same input is typed in that language.

Where it is stored

Persistent files live under:

<AppDataLocation>/lnvirtualkeyboard/userfreq/<bcp47>.bin

<AppDataLocation> is the host application's writable data location (Qt QStandardPaths::AppDataLocation). There is one file per language tag (for example en.bin, zh-Hant.bin).

Opt-out and session-only mode

Persistence is controlled by rememberLearning (default true). Set it to false for session-only learning (in memory, per language; nothing is written to disk):

VirtualKeyboard { rememberLearning: false }

Lnvk.rememberLearning = false

There is no separate "clear history" API on the public QML surface. To wipe stored data, delete the userfreq directory under your application's data location, or keep rememberLearning off for kiosk and privacy-sensitive deployments.

Automatic exclusions

Learning and prediction are automatically suppressed for sensitive or special-purpose fields, regardless of rememberLearning. When inputMethodHints include any of ImhNoPredictiveText, ImhSensitiveData, ImhHiddenText, ImhDigitsOnly, ImhFormattedNumbersOnly, ImhDialableCharactersOnly, ImhDate, ImhTime or ImhPreferNumbers, the engine disables prediction (effectivePredictionEnabled is false) and IME interaction where applicable, so passwords, PINs, and numeric or date fields do not contribute to the learning store.

See also the input method hints table below.

Input method hints

The keyboard adapts automatically to inputMethodHints on the focused TextInput or TextEdit:

HintLayoutIMEPrediction
Qt.ImhNoneProfile layoutonon (if enabled)
Qt.ImhDigitsOnlyNumeric keypadoffoff
Qt.ImhDialableCharactersOnlyDial padoffoff
Qt.ImhFormattedNumbersOnlyNumbers with decimal/signoffoff
Qt.ImhDateDate input layoutoffoff
Qt.ImhTimeTime input layoutoffoff
Qt.ImhPreferNumbersSame as digits-onlyoffoff
Qt.ImhEmailCharactersOnlyEmail keys on alphabetic layoutoffon
Qt.ImhUrlCharactersOnlyURL keys on alphabetic layoutoffon
Qt.ImhNoPredictiveTextProfile layoutoffoff
Qt.ImhSensitiveDataProfile layoutoffoff
Qt.ImhHiddenTextPassword mode (numeric if also sensitive)offoff

When IME is off, any active composition is cleared. The candidate bar remains visible for word prediction when effectivePredictionEnabled is true. When imeInteractionEnabled is true, the bar also appears during IME composition and post-commit suggestions.

Dictionary paths

Set LNVK_DICT_DIR to the directory that contains layouts.lnlay (typically share/lnvirtualkeyboard/dictionaries/). Binary dictionary files resolve from a storage subtree:

  • LNVK_DICT_STORAGE=compressed (default): smaller on-disk layout
  • LNVK_DICT_STORAGE=mmap: less memory for Chinese and Japanese input, with larger files

To omit prediction, n-gram, matrix, or bigram files at deploy time, use LNVK_DICT_PROFILE / LNVK_DICT_FEATURES with LNVKConfig.cmake. Details: Advanced deployment — Dictionary storage and profiles.