if (e.KeyCode == KeyCodes.Enter)
// Do stuff!
private void textBox1_KeyDown(object sender, KeyEventArgs e)
if (e.KeyCode == Keys.Enter)
// Enter (return) was pressed.
// ... Call a custom method when user presses this key.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)