每当按下向下箭头键时如何检测? [英] How can I detect whenever DOWN ARROW Key is pressed?

查看:87
本文介绍了每当按下向下箭头键时如何检测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我最近一直在做一个项目,唯一剩下要做的就是每当按下向下箭头键时都有一个探测器。

向下箭头键只能触发检查某个复选框,这也必须与计时器一起工作。

问题是我不知道如何制作向下箭头按键检测器(我已经得到了复选框和计时器准备好了)。很高兴,如果你能提供帮助。 :)

So, I''ve been working on a project recently, and the only thing remaining to do is a detector to whenever down arrow key is pressed.
The down arrow key can only trigger when a certain check box is checked and this will have to work with a timer either.
The problem is that I''ve got no idea how to make the down arrow key press detector(I''ve got the check box and timer ready tho). Glad if you can help. :)

推荐答案

您好,是否尝试在WinForms或WPF中捕获此键事件?
Hi there, are you trying to capture this key event in WinForms or WPF?


@Aimee Bailey


我正在尝试使用Windows窗体执行此操作。
@Aimee Bailey
I''m trying to do this using Windows Forms.


In WinForms有各种可重载的事件来处理键盘操作; OnKeyDown,OnKeyUp和OnKeyPressed。对于此示例,我将使用OnKeyDown和OnKeyUp,因为OnKeyPressed仅提供不包含箭头键的char。这是一个示例,展示了你是如何做到的:

In WinForms there are various overload-able events that handle keyboard actions; OnKeyDown, OnKeyUp and OnKeyPressed. For this example i''ll use OnKeyDown and OnKeyUp as OnKeyPressed only provides a char which does not include the arrow keys. Here is an example showing how you''d do it:

展开 | 选择 | Wrap | 行号


这篇关于每当按下向下箭头键时如何检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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