How to query keyboard modifiers in QML?

2k Views Asked by At
1

There are 1 best solutions below

2
On

In QML there exists the KeyEvent (see here for further details) that has a property named modifers.
It contains a bitwise combination of the available modifiers.

It follows an example taken directly from the documentation above mentioned:

Item {
    focus: true
    Keys.onPressed: {
        if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier))
            doSomething();
    }
}

For the complete list of the available modifiers, please refer to the official documentation.