[UWP]如何检测按钮中的Enter键? [英] [UWP] How can I detect Enter Key Down in a Button?

查看:123
本文介绍了[UWP]如何检测按钮中的Enter键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到在UWP中当按钮处于焦点并且从键盘按下Enter键时,会触发Click事件。但是,当我按住回车键几秒钟时,会触发按键事件。如何让enter键调用另一个函数
键而不是Click事件?

I noticed that in UWP when a button is in focus and the Enter key is pressed from Keyboard, the Click Event is triggered. But, when I hold the enter key for some seconds, the key down event is triggered. How can I make the enter key to call another function of key down instead of Click Event?

推荐答案

嗨SubashAdhi,

Hi SubashAd

如您所知,当我们按Enter键一次时,Click事件将被触发。

As you know, when we press the Enter key once, the Click event will be fired.

如果您想按一下Enter键以触发KeyDown事件,您应该能够自定义Button控件。似乎Enter键将触发Click事件是设计的。

If you want to press the Enter once to fire the KeyDown event, you should able to custom a Button control. It seems the Enter key will fire the Click event is by design.

如果您想按住回车键几秒钟来触发KeyDown事件而不触发Click事件,应该能够使用Tap事件代替Click事件。

If you want to hold the enter key for some seconds to fire the KeyDown event and not fire the Click event, you should able to use Tap event to instead Click event.

最好的问候,

Jayden Gu

Jayden Gu


这篇关于[UWP]如何检测按钮中的Enter键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆