How to check if the Shift key is held and Any key is pressed in KeyPress using WinForms with C#

1 Answer

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

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((ModifierKeys & Keys.Shift) == Keys.Shift)
            {
                MessageBox.Show("Shift held + any key is pressed");
            }
        }
    }
}




/*
run:

Shift held + any key is pressed

*/

 



answered Mar 26, 2024 by avibootz
...