- Qt 6.10
- Qt Virtual Keyboard
- QML Types
- QtQuick.VirtualKeyboard
- InputEngine
- Qt Virtual Keyboard | Commercial or GPLv3

# InputEngine QML Type

Maps the user input to the input methods. More...

Import Statement: | `import QtQuick.VirtualKeyboard`
In C++: | QVirtualKeyboardInputEngine

- List of all members, including inherited members

## Properties

- activeKey : int
- inputMethod : InputMethod
- inputMode : int
- inputModes : list<int>
- patternRecognitionModes : list<int> `(since QtQuick.VirtualKeyboard 2.0)`
- previousKey : int
- wordCandidateListModel : SelectionListModel
- wordCandidateListVisibleHint : bool

## Signals

- void activeKeyChanged(int key)
- void inputMethodChanged()
- void inputMethodReset()
- void inputMethodUpdate()
- void inputModeChanged()
- void inputModesChanged()
- void patternRecognitionModesChanged() `(since QtQuick.VirtualKeyboard 2.0)`
- void previousKeyChanged(int key)
- void virtualKeyClicked(int key, string text, int modifiers)

## Methods

- Trace traceBegin(int traceId, int patternRecognitionMode, var traceCaptureDeviceInfo, var traceScreenInfo) `(since QtQuick.VirtualKeyboard 2.0)`
- bool traceEnd(Trace trace)
- void virtualKeyCancel()
- bool virtualKeyClick(int key, string text, int modifiers)
- bool virtualKeyPress(int key, string text, int modifiers, bool repeat)
- bool virtualKeyRelease(int key, string text, int modifiers)

## Detailed Description

The input engine is responsible for routing input events to input methods. The actual input logic is implemented by the input methods.

The input engine also includes the default input method, which takes care of default processing if the active input method does not handle the event.

## Property Documentation

activeKey : int `[read-only]`

Currently pressed key.

inputMethod : InputMethod

Use this property to set the active input method, or to monitor when the active input method changes.

inputMode : int

Use this property to get or set the current input mode. The InputEngine::inputModes property provides the list of valid input modes for the current input method and locale.

The predefined input modes are:

- `InputEngine.InputMode.Latin` The default input mode for latin text.
- `InputEngine.InputMode.Numeric` Only numeric input is allowed.
- `InputEngine.InputMode.Dialable` Only dialable input is allowed.
- `InputEngine.InputMode.Pinyin` Pinyin input mode for Chinese.
- `InputEngine.InputMode.Cangjie` Cangjie input mode for Chinese.
- `InputEngine.InputMode.Zhuyin` Zhuyin input mode for Chinese.
- `InputEngine.InputMode.Hangul` Hangul input mode for Korean.
- `InputEngine.InputMode.Hiragana` Hiragana input mode for Japanese.
- `InputEngine.InputMode.Katakana` Katakana input mode for Japanese.
- `InputEngine.InputMode.FullwidthLatin` Fullwidth latin input mode for East Asian languages.
- `InputEngine.InputMode.Greek` Greek input mode.
- `InputEngine.InputMode.Cyrillic` Cyrillic input mode.
- `InputEngine.InputMode.Arabic` Arabic input mode.
- `InputEngine.InputMode.Hebrew` Hebrew input mode.
- `InputEngine.InputMode.ChineseHandwriting` Chinese handwriting.
- `InputEngine.InputMode.JapaneseHandwriting` Japanese handwriting.
- `InputEngine.InputMode.KoreanHandwriting` Korean handwriting.
- `InputEngine.InputMode.Thai` Thai input mode.
- `InputEngine.InputMode.Stroke` Stroke input mode for Chinese.
- `InputEngine.InputMode.Romaji` Romaji input mode for Japanese.
- `InputEngine.InputMode.HiraganaFlick` flick input mode for Japanese.

inputModes : list<int> `[read-only]`

The list of available input modes is dependent on the input method and locale. This property is updated when either of the dependencies change.

patternRecognitionModes : list<int> `[read-only, since QtQuick.VirtualKeyboard 2.0]`

The list of available pattern recognition modes.

Possible values:

Constant | Description
--- | ---
`InputEngine.PatternRecognitionMode.None` | Pattern recognition is not available.
`InputEngine.PatternRecognitionMode.PatternRecognitionDisabled` | `obsolete` - Use `None` instead.
`InputEngine.PatternRecognitionMode.Handwriting` | Pattern recognition mode for handwriting recognition.
`InputEngine.PatternRecognitionMode.HandwritingRecoginition` | `obsolete` - Use `Handwriting` instead.

This property was introduced in QtQuick.VirtualKeyboard 2.0.

previousKey : int `[read-only]`

Previously pressed key.

wordCandidateListModel : SelectionListModel `[read-only]`

Use this property to access the list model for the word candidate list.

wordCandidateListVisibleHint : bool `[read-only]`

Use this property to check if the word candidate list should be visible in the UI.

## Signal Documentation

void activeKeyChanged(int key)

Indicates that the active key has changed.

Note: The corresponding handler is `onActiveKeyChanged`.

void inputMethodChanged()

Indicates that the input method has changed.

Note: The corresponding handler is `onInputMethodChanged`.

void inputMethodReset()

Emitted when the input method needs to be reset.

Note: This signal is automatically connected to QVirtualKeyboardAbstractInputMethod::reset() and InputMethod::reset() when the input method is activated.

Note: The corresponding handler is `onInputMethodReset`.

void inputMethodUpdate()

Note: This signal is automatically connected to QVirtualKeyboardAbstractInputMethod::update() and InputMethod::update() when the input method is activated.

Note: The corresponding handler is `onInputMethodUpdate`.

void inputModeChanged()

Indicates that the input mode has changed.

Note: The corresponding handler is `onInputModeChanged`.

void inputModesChanged()

Indicates that the available input modes have changed.

Note: The corresponding handler is `onInputModesChanged`.

`[since QtQuick.VirtualKeyboard 2.0]` void patternRecognitionModesChanged()

Indicates that the available pattern recognition modes have changed.

The predefined pattern recognition modes are:

- `InputEngine.PatternRecognitionMode.None` Pattern recognition is not available.
- `InputEngine.PatternRecognitionMode.PatternRecognitionDisabled` `obsolete` Use InputEngine.PatternRecognitionMode.None
- `InputEngine.PatternRecognitionMode.Handwriting` Pattern recognition mode for handwriting recognition.
- `InputEngine.PatternRecognitionMode.HandwritingRecoginition` `obsolete` Use InputEngine.PatternRecognitionMode.Handwriting

Note: The corresponding handler is `onPatternRecognitionModesChanged`.

This signal was introduced in QtQuick.VirtualKeyboard 2.0.

void previousKeyChanged(int key)

Indicates that the previous key has changed.

Note: The corresponding handler is `onPreviousKeyChanged`.

void virtualKeyClicked(int key, string text, int modifiers)

Indicates that the virtual key was clicked with the given text and modifiers. This signal is emitted after the input method has processed the key event.

Note: The corresponding handler is `onVirtualKeyClicked`.

## Method Documentation

`[since QtQuick.VirtualKeyboard 2.0]` Trace traceBegin(int traceId, int patternRecognitionMode, var traceCaptureDeviceInfo, var traceScreenInfo)

Starts a trace interaction with the input engine.

The trace is uniquely identified by the traceId. The input engine will assign the id to the Trace object if the input method accepts the event.

The patternRecognitionMode specifies the recognition mode used for the pattern.

If the current input method accepts the event it returns a Trace object associated with this interaction. If the input method discards the event, it returns a null value.

The traceCaptureDeviceInfo provides information about the source device and the traceScreenInfo provides information about the screen context.

By definition, the Trace object remains valid until the traceEnd() method is called.

The trace interaction is ended by calling the InputEngine.traceEnd() method.

This method was introduced in QtQuick.VirtualKeyboard 2.0.

bool traceEnd(Trace trace)

Ends the trace interaction with the input engine.

The trace object may be discarded at any point after calling this function.

The function returns true if the trace interaction was accepted (i.e. the touch events should not be used for anything else).

void virtualKeyCancel()

Reverts the active key state without emitting the key event. This method is useful when the user discards the current key and the key state needs to be restored.

bool virtualKeyClick(int key, string text, int modifiers)

Emits a key click event for the given key, text and modifiers. Returns `true` if the key event was accepted by the input engine.

bool virtualKeyPress(int key, string text, int modifiers, bool repeat)

Called by the keyboard layer to indicate that key was pressed, with the given text and modifiers.

The key is set as an active key (down key). The actual key event is triggered when the key is released by the virtualKeyRelease() method. The key press event can be discarded by calling virtualKeyCancel().

The key press also initiates the key repeat timer if repeat is `true`.

Returns `true` if the key was accepted by this input engine.

See also virtualKeyCancel() and virtualKeyRelease().

bool virtualKeyRelease(int key, string text, int modifiers)

Releases the key at key. The method emits a key event for the input method if the event has not been generated by a repeating timer. The text and modifiers are passed to the input method.

Returns `true` if the key was accepted by the input engine.