title: Deleting characters in a textbox
body: <p>I am trying to configure the TextBox so that when the <kbd>ctrl</kbd> + <kbd>delete</kbd> keys are pressed the TextBox is cleaned.</p>
  
  <p>This is my entire code:</p>
  
  <pre><code>using System;
  using System.Data;
  using System.Data.SqlClient;
  using System.Drawing;
  using System.Windows.Forms;
  
  namespace pruebaMensajes
  {
      public partial class Providus : Form{
          public Providus(){
              InitializeComponent();
              txtUsuario.MaxLength = 20;//max character
              txtContrasena.MaxLength = 16;
              txtContrasena.PasswordChar = '*';//type
          }
  
          private void Button1_Click(object sender, EventArgs e){//para el login
              string usuario = txtUsuario.Text;
              string contrasena = txtContrasena.Text;
              SqlConnection con = new SqlConnection("stringChain");
              SqlDataAdapter sda = new SqlDataAdapter("SELECT COUNT(*) FROM usuariosProvidus WHERE usuario='" + usuario + "' AND contrasena='" + contrasena + "'", con);
              DataTable dt = new DataTable();
              sda.Fill(dt);
              if (dt.Rows[0][0].ToString() == "1"){
                  this.Hide();
                  new Inicio().Show();
              } else{
                  MessageBox.Show("Wrong user o password.","Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
              }
          }
  
          private void Providus_Load(object sender, EventArgs e){ }
  
          private void TxtContrasena_KeyPress_1(object sender, KeyPressEventArgs e){//manejar el enter para el login en contraseña
              if ((int)e.KeyChar == (int)Keys.Enter){
                  string usuario = txtUsuario.Text;
                  string contrasena = txtContrasena.Text;
                  SqlConnection con = new SqlConnection("Data Source=PC-HELP;Initial Catalog=apiTiny;Integrated Security=True");
                  SqlDataAdapter sda = new SqlDataAdapter("SELECT COUNT(*) FROM usuariosProvidus WHERE usuario='" + usuario + "' AND contrasena='" + contrasena + "'", con);
                  DataTable dt = new DataTable();
                  sda.Fill(dt);
                  if (dt.Rows[0][0].ToString() == "1"){
                      this.Hide();
                      new Inicio().Show();
                  }else if(txtUsuario.Text==String.Empty){
                      lblMensaje.BackColor = Color.FromArgb(255, 0, 0);
                      lblMensaje.Text = "Wrong user.";
                      txtUsuario.Focus();
                  }else if (txtContrasena.Text == String.Empty){
                      lblMensaje.BackColor = Color.FromArgb(255, 0, 0);
                      lblMensaje.Text = "Wrong password.";
                      txtContrasena.Focus();
                  }
              }
          }
  
          private void TxtUsuario_KeyPress(object sender, KeyPressEventArgs e){//enter para el txt usuario
              if ((int)e.KeyChar == (int)Keys.Enter){
                  string usuario = txtUsuario.Text;
                  string contrasena = txtContrasena.Text;
                  SqlConnection con = new SqlConnection("Data Source=PC-HELP;Initial Catalog=apiTiny;Integrated Security=True");
                  SqlDataAdapter sda = new SqlDataAdapter("SELECT COUNT(*) FROM usuariosProvidus WHERE usuario='" + usuario + "' AND contrasena='" + contrasena + "'", con);
                  DataTable dt = new DataTable();
                  sda.Fill(dt);
                  if (dt.Rows[0][0].ToString() == "1"){
                      this.Hide();
                      new Inicio().Show();
                  }
                  else if (txtUsuario.Text == String.Empty){
                      lblMensaje.BackColor = Color.FromArgb(255, 0, 0);
                      lblMensaje.Text = "Worng user.";
                      txtUsuario.Focus();
                  }
                  else if (txtContrasena.Text == String.Empty){
                      lblMensaje.BackColor = Color.FromArgb(255, 0, 0);
                      lblMensaje.Text = "Worng password.";
                      txtContrasena.Focus();
                  }
              };
          }
  
          private void TxtUsuario_KeyDown(object sender, KeyEventArgs e){
              if (e.KeyCode == Keys.Delete &amp;&amp; e.Modifiers == Keys.ControlKey){
                  e.Handled = true;
                  txtUsuario.Text = "";
              }
          }
  
          private void TxtContrasena_KeyDown(object sender, KeyEventArgs e){
              if (e.KeyCode == Keys.Delete &amp;&amp; e.Modifiers == Keys.Control){
                  e.Handled = true;
                  txtContrasena.Text = "";
              }
          }
      }
  }
  </code></pre>
  
  <p>Does anyone know how I can do it? Cause when i press the keys <kbd>ctrl</kbd> + <kbd>delete</kbd> this adds a character instead of clearing the textbox. 
  I use the keydown event to realize this but it is not working for me </p>
  
  <p>In a gif: </p>
  
  <p><a href="https://i.stack.imgur.com/RELIz.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RELIz.gif" alt="enter image description here"></a></p>