bool bUndoDown = false;
// checking for ctrl key
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Z:
if (bUndoDown)
break;
if (e.Modifiers == (Keys.Control | Keys.Shift))
{
bUndoDown = true;
Console.WriteLine("redo pressed");
}
else if (Control.ModifierKeys == Keys.Control)
{
bUndoDown = true;
undodebugcnt++;
Console.WriteLine("undo pressed "+undodebugcnt);
}
break;
}
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (bUndoDown)
{
if (e.KeyCode==Keys.Z)
{
bUndoDown = false;
}
}
}
I originally thought I could get this to work with just the KeyPressed event, but had to do it a little deeper in the KeyDown and KeyUp events.
No comments:
Post a Comment