Declare a boolean isKeyDown
, in theKeyDown
Event, set the boolean to true. In the KeyUp
event, set the boolean to false.
This is sample code
bool isKeyDown=false;
public void control_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(isKeyDown)
return;
isKeyDown=true;
// do what you want to do
}
public void control1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
isKeyDown=false;
// do you key up event, if any.
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…