How to check if the control (Ctrl) + C key is pressed in KeyDown using WinForms with C#

1 Answer

0 votes
namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control)
            {
                MessageBox.Show("Ctrl + C is pressed");
            }
        }
    }
}




/*
run:

Ctrl + C is pressed

*/

 



answered Mar 25, 2024 by avibootz
...