Tastendruck abfragen (KeyDown, KeyPress)

// KeyDown
private void MyForm_KeyDown(object sender, KeyEventArgs e)
{
    switch (e.KeyCode)
    {
        case Keys.Up: // CRSR hoch
            break;
        case Keys.Down: // CRSR runter
            break;
        case Keys.Delete: // ENTF
            break;
        case Keys.Enter: // Enter
            break;
        case Keys.Escape: // ESC
            break;
        default:
            break;
    }
}

// KeyPress
private void MyForm_KeyPress(object sender, KeyPressEventArgs e)
{
    switch (e.KeyChar)
    {
        case (char)(int)Keys.Up: // CRSR hoch
            break;
        case (char)(int)Keys.Down: // CRSR runter
            break;
        case (char)(int)Keys.Delete: // ENTF
            break;
        case (char)(int)Keys.Enter: // Enter
            break;
        case (char)(int)Keys.Escape: // ESC
            break;
        default:
            break;
    }
}

Schreibe einen Kommentar