I've recently started using WPF for developing my applications. Now I've come to a point where I need some tips on good design when it comes to key combination handling.
This is what I'm using at the moment:
private void Grid_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (Keyboard.Modifiers == ModifierKeys.Control)
{
switch (e.Key)
{
case Key.Up: PreviousLine(); break;
case Key.Down: NextLine(); break;
case Key.Return: NextLine(); break;
}
}
else if (Keyboard.Modifiers == ModifierKeys.Shift)
{
switch (e.Key)
{
case Key.Return: PreviousLine(); break;
}
}
}
As you can imagine, this will start to get really ugly, really fast.
Do you have any tips which would improve the code?