I have some buttons and associated functions in my qml code, I want one button to be triggered when the enter key is pressed. All the buttons are handled by onClick event, ie, when the button is clicked my mouse,it executes the associated functions. I want to execute the click when the enter key is pressed
You can react to different signals:
Button {
id: _button
text: "Button"
function activate() { console.debug("Button activated"); }
onClicked: _button.activate()
Keys.onReturnPressed: _button.activate() // Enter key
Keys.onEnterPressed: _button.activate() // Numpad enter key
}
Your button needs the focus to be notified about the key-press. If you want one specific button to have the focus by default, just add in the button
focus: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With