在Windows窗体上,如何检测Shift + LWin + Left键的组合?
我在表单上尝试了以下内容(使用KeyPreview = true)但没有成功。
private void frmPlaceholderRectangle_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers == Keys.Shift && (e.KeyCode == (Keys.Left | Keys.LWin)))
{
//Do Something
return;
}
}
答案 0 :(得分:0)
这是一个足够的临时解决方法:
private bool _ShiftWin = false;
private void frmPlaceholderRectangle_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.LWin)
{
_ShiftWin = true;
txtShowName.Text = "Shift+Win Down at " + DateTime.Now.ToString();
}
}
private void frmPlaceholderRectangle_KeyUp(object sender, KeyEventArgs e)
{
if (_ShiftWin && e.KeyCode == Keys.Left)
{
txtShowName.Text = "Left Key Up at " + DateTime.Now.ToString();
}
if (_ShiftWin && e.KeyCode == Keys.LWin)
{
txtShowName.Text = "Shift+Win Up at " + DateTime.Now.ToString();
_ShiftWin = false;
}
}