// Place the following code into the // #region Windows Form Designer generated code this.txtEnter.KeyDown += new KeyEventHandler(txtEnter_KeyDown); // Place the following function where ever the // #region Windows Form Designer generated code // is located or you can move it elsewhere if you like, // but you will then need to make it public. private void txtEnter_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { // Your code here. } }