How to use KeyDown event in Maui? #21557
-
How to use KeyDown event in Maui? I have a button and I want it to be clicked when I press enter. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I wrote a plugin that provides key events. You might use that approach. Use the plugin or just snag the code. I assume you would execute the same command or event you have bound to that button, not actually try to simulate a click. Sample: https://github.com/davidortinau/GuessWord Related, if you want to execute a command when Return is pressed on an <Entry Placeholder="Type message"
Text="{Binding UserInput}"
ReturnCommand="{Binding SendMessageCommand}"
/> |
Beta Was this translation helpful? Give feedback.
I wrote a plugin that provides key events. You might use that approach. Use the plugin or just snag the code. I assume you would execute the same command or event you have bound to that button, not actually try to simulate a click.
Sample: https://github.com/davidortinau/GuessWord
Plugin: https://github.com/davidortinau/Plugin.Maui.KeyListener
Related, if you want to execute a command when Return is pressed on an
Entry
field, there's a propReturnCommand
for that.