[Interest] Press and hold keyboard key to bring up menu in QML

Elvis Stansvik elvstone at gmail.com
Fri Apr 1 12:45:39 CEST 2016

Hi folks,

I have a full screen, page based Qt Quick 2 application. Input is
contstrained by the hardware to the Left/Right/Return keyboard keys,
so is quite limited, and navigation between pages is done using
buttons on each page which handle return presses using (most of the
time) Keys.onReturnPressed and navigation between buttons and other
items with KeyNavigation.left/right.

I now have the need to provide a special global shortcut: On almost
all of the screens, holding the Enter key for 3 seconds should bring
the user immediately to a sort of start screen, where he/she can
choose to go into Settings or Power Off. Kind of like how holding the
power button on a phone often brings up a power off/flight mode menu.

I'm struggling to find a good way to handle this centrally: since
Enter presses are normally accepted (swallowed) by my various buttons
and other input items on the pages, where can I put some central key
press/release handler in which to start/stop a timer (to determine if
it was a long 3 sec press or not)?

My pages are FocusScopes stuffed in a StackView inside a Window.

Many thanks for any advice. Has noone had this kind of requirement
before? (Global "hold key" shortcut).


More information about the Interest mailing list