Additonally if you use the KeyDown or KeyUp event check to see what the key is, is simple by using the Keys enumerable.
private void TextBox1_KeyUp(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
{
MessageBox.Show("You pressed enter");
}
}
KeyPress is useful to allow only letters or numbers for example.
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if(!Char.IsControl(e.KeyChar) && !Char.IsNumber(e.KeyChar))
{
e.Handled = true;
}
}
The code above will not allow anything that isn't a control (ENTER, ESCAPE, CTRL etc or a number)