我可以确定Ctrl键preSS是左Ctrl键或右Ctrl? [英] Can I determine whether a Ctrl key press is Left Ctrl or Right Ctrl?

查看:164
本文介绍了我可以确定Ctrl键preSS是左Ctrl键或右Ctrl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要确定一个Ctrl键是左Ctrl键或右Ctrl键时,它是pssed $ P $。我怎样才能做到这一点?

I want to determine whether a Ctrl key is left Ctrl or right Ctrl key when it is pressed. How can I do this?

推荐答案

AFAIK你不能从.NET中访问这些信息。

AFAIK you can't access this information from within .net.

不过,您可以使用Win32 API GetAsyncKeyState 来测试是否特定的键是目前下跌,这样就可以区分左,右Ctrl键。 (如果你正在编写一个游戏,这是更可能很好地帮助你比的keydown的处理程序,如GetAsyncKeyState测试是否该键被按下现在,而不是它是否是pressed在过去的一段时间,这给相当好的响应)。

However, you can use the Win32 API GetAsyncKeyState to test if specific keys are currently down, and this can differentiate the left and right ctrl keys. (If you're writing a game this is more likely to work well for you than Keydown handlers, as GetAsyncKeyState tests whether the key is down "now" rather than whether it was pressed "at some time in the past", which gives considerably better responsiveness).

这篇关于我可以确定Ctrl键preSS是左Ctrl键或右Ctrl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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