C

Keys QML Type

Provides key handling to Items. More...

Import Statement: import QtQuick
Since: Qt Quick Ultralite 1.0

Signals

Detailed Description

All visual primitives support key handling via the Keys attached property. Key input can be handled via the onPressed and onReleased signal handlers.

These signal handlers have a event parameter, which contains details about the KeyEvent.

Example Usage

The following example shows how the general onPressed handler can be used to test for a certain key:

Item {
    anchors.fill: parent
    Keys.onPressed: {
        if (event.key == Qt.Key_Left) {
            console.log("move left");
        }
    }
}

See Qt::Key for the list of keyboard codes.

Note: Key events are emitted only when you build and run the application for the Qt desktop backend.

See also KeyEvent.

Signal Documentation

pressed(KeyEvent event)

This signal is emitted when a key has been pressed. The event parameter provides information about the event.

Note: The corresponding handler is onPressed.

Note: The corresponding handler is onPressed.


released(KeyEvent event)

This signal is emitted when a key has been released. The event parameter provides information about the event.

Note: The corresponding handler is onReleased.

Note: The corresponding handler is onReleased.


Available under certain Qt licenses.
Find out more.