Reputation: 1630
I wish to have a sequence shortcut for the program I'm developing (in C# .net) to access various buttons in the menu system.
For example: Ctrl + W, O
First, the user would press Ctrl + W, followed by O
Visual studio uses this method for quite a few of it's menu shortcuts.
When I am editing a menu however, I'm limited to only one shortcut Ctrl + W or just O, I cannot sequence them.
Is this possible to do with the existing framework?
Upvotes: 8
Views: 315
Reputation: 6444
Simply you could do this:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (previousKeyEvent != null)
{
if (previousKeyEvent.Modifiers == Keys.Control && previousKeyEvent.KeyCode == Keys.W && e.KeyCode == Keys.O)
{
MessageBox.Show("Ctrl + W then O");
}
else
{
MessageBox.Show("Not handled");
previousKeyEvent = null;
}
else
previousKeyEvent = e;
}
}
Things to consider
Upvotes: 2