Detect "KeyDown" event in qml
Solved
QML and Qt Quick
-
Hi
How can I detect whether a key (e.g.Qt.Key_Space
) is down or not? (inside aFocusScope
)
I want to get a single event for start of press only.
Keys.onPressed
is not useful because it is triggered contiguously when I press and hold down space key, the same is true forKey.onReleased
Very strange behavior, because these handlers are for this purpose, I think :|
Qt 5.12.4Thanks
-
You need to use the Keys.onRelease only. Since it is repeate key try to use isAutoRepeat set to true to detect that key is pressed continously.
-
Thanks
using below code worksKeys.onReleased: { if(event.key === Qt.Key_Space && !event.isAutoRepeat) { // code here } }