kejpa Posted December 31, 2004 Posted December 31, 2004 Hi, How can I detect if the Shift button is pressed when handling a button click event? Is it stated somewhere in the EventArgs parameter or do I have to have a form variable that contains which buttons (Shift/Ctrl/Alt) that currently are pressed? TIA /Kejpa Quote
BlackStone Posted December 31, 2004 Posted December 31, 2004 Use the static property ModifierKeys of the Control class: private void button1_Click(object sender, EventArgs e) { if (Control.ModifierKeys == Keys.Shift) { MessageBox.Show("Shift Pressed"); } } Quote "For every complex problem, there is a solution that is simple, neat, and wrong." - H. L. Mencken
kejpa Posted December 31, 2004 Author Posted December 31, 2004 Use the static property ModifierKeys of the Control class: That's a simple one. :o Thanksalot /Kejpa Quote
BlackStone Posted December 31, 2004 Posted December 31, 2004 I learned the hard way. I was originally using the GetKeyboardState API method :) Quote "For every complex problem, there is a solution that is simple, neat, and wrong." - H. L. Mencken
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.