本文介绍了如何检查按下的键是否为功能键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
如何检查按下的键是否为功能键?
请回复我.
在此先谢谢您..
Hai all,
How to check the pressed key is a function key or not..?
please reply me..
Thanks in advance..
推荐答案
void KeyUpEvent(object sender, KeyEventArgs e)
{
if (e.KeyCode >= Keys.F1 && e.KeyCode <= Keys.F24)
{
}
}
public static bool IsFunctionKey(Keys k)
{
return k >= Keys.F1 && k <= Keys.F24;
}
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form2_KeyUp);
在add
后面的代码中
in code behind add
private void Form2_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F1 || e.KeyCode == Keys.F2 || e.KeyCode == Keys.F3 ||e.KeyCode == Keys.F4 ||
e.KeyCode == Keys.F5 ||e.KeyCode == Keys.F6 ||e.KeyCode == Keys.F7 ||e.KeyCode == Keys.F8 ||
e.KeyCode == Keys.F9 ||e.KeyCode == Keys.F10 ||e.KeyCode == Keys.F11 ||e.KeyCode == Keys.F12 )
{
MessageBox.Show(string.Format("Function Key {0} is pressed", e.KeyCode));
}
}
这篇关于如何检查按下的键是否为功能键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!