请帮助我确定Shift键是否按下 [英] Please help me to determine whether shift key is down

查看:115
本文介绍了请帮助我确定Shift键是否按下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我确定Shift键是否按下.

Please help me to determine whether shift key is down.

推荐答案

要测试虚拟键的状态,您可以使用 GetAsyncKeyState() [
To test the status of a virtual-key you could use the GetAsyncKeyState()[^] function: it tell you if the required key is currently pressed or not, and if it has been pressed since the last time the function was called.

SHORT shift_status = GetAsyncKeyState(VK_SHIFT);
if (shift_status & 0x8000)
{
   // The shift key is currently pressed
}
else if (shift_status & 0x0001)
{
   // The shift key has been pressed since the last call to GetAsyncKeyState()
   // NOTE: you cannot rely on this information! See the remarks
   // section on the GetAsyncKeyState() documentation
}



如果要区分左移键和右移键,请使用VK_LSHIFT和/或VK_RSHIFT而不是VK_SHIFT.



If you want to distinguish between the left and right shift keys, use VK_LSHIFT and/or VK_RSHIFT instead than VK_SHIFT.


您好,当您按下某个键时,可以使用
GetAsyncKeyState();

代码


如果(GetAsyncKeyState(VK_SHIFT)& 0x8000)
{
//按键当前处于按下状态
}

hello, when you press a key you can use the
GetAsyncKeyState();

Code


if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
{
// The key is currently down
}


这篇关于请帮助我确定Shift键是否按下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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