如何同时注册多个密钥? [英] How to register multiple keys at the same time ?

查看:95
本文介绍了如何同时注册多个密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

任何人都可以帮助我在c#中同时检测多个键

例如:同时显示key.up和key.left


感谢您的任何帮助,谢谢您

问候

hey guys,

can anybody help me detecting multiple keys at the same time in c#

e.g : key.up and key.left at the same time


any help is appreciated thank you in advance

regards

推荐答案

事件处理程序不处理键状态,仅处理事件.而且事件永远不会在一起. 您不能同时按向左键和向上键;这些事件之一将永远是第一个.

也就是说,您始终只需要检测按下和释放一个键的事件.您应该从这些事件中推断出键状态,并在事件之间的数据中记住它.这样,您就可以始终了解感兴趣的键的状态.

我现在不想给您代码示例,因为您甚至都没有标记要使用的UI库(总是标记它!).

—SA
Event handlers do not deal with key status, they deal with events only; and the events are never comes together. You cannot press Left and Up at the same time; one of those events will always be the first.

That said, you always need to detect the event of pressing and releasing of one key only. You should infer the key state from these event and remember it in your data between events. This way, you can always know the state of the keys of interest.

I don''t want to give you a code sample right now, because you did not even tag a UI library you want to use (always tag it!).

—SA


这篇关于如何同时注册多个密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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