Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9184355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:01:37+00:00 2026-06-17T19:01:37+00:00

I have a little problem. I have a form, which is my login form.

  • 0

I have a little problem. I have a form, which is my login form. Then I also have another form, which is my add user form. When I click on the login button for the login form, it needs to check if the shift and control keys are both held down on the same time. Ff both of them are not pressed, then the add user form should not open. but if they are both pressed down and the login button is clicked, it should show the form.

What I have:

if (Control.ModifierKeys == (Keys.Control & Keys.Shift))
{
    //Show the form
}

But this is not working.

When I have:

if (Control.ModifierKeys == Keys.Shift)
{
    //Show the form
}

Then it works.

How can I achieve this with both buttons pressed down, control and shift?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:01:38+00:00Added an answer on June 17, 2026 at 7:01 pm

    Try Keys.Control | Keys.Shift.


    This is a flags enumeration; each value is represented by a separate bit in the underlying int.

    Keys.Control & Keys.Shift results in a zero value – e.g. if Control is 0001 and Shift is 0010, the bitwise-& is 0000.

    Control.ModifierKeys will be 0000 if and only if the user is holding no modifier keys down, so the == will only result in true if the user isn’t holding anything down.

    Keys.Control | Keys.Shift, on the other hand, results in a value that says “both these flags” – e.g. if Control is 0001 and Shift is 0010, the bitwise-| is 0011.

    Control.ModifierKeys will be 0011 if and only if the user is holding both Ctrl and Shift down, so the == will only result in true in this case.


    Alternatively, you could break this down as

    bool ctrlIsHeldDown  = (Control.ModifierKeys & Keys.Control) == Keys.Control;
    bool shiftIsHeldDown = (Control.ModifierKeys & Keys.Shift)   == Keys.Shift;
    if (CtrlIsHeldDown && shiftIsHeldDown)
    {
        ...
    }
    

    The (value & x) == x construct checks whether an individual flag x is set, and after that it’s jsut standard boolean logic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem with javascript form submit issue, here is the script
I have a windows form application which needs to be the TopMost. I've set
I have a little problem with a .hover() in IE8 which works in FF,
Let's say I have a SessionsController , which controls user login and logout, but
I'm trying to write a little form which accepts some user input, and on
I have little problem with a replacement of a little part in an url.
I have little problem in regular expressin creation. Expected input: blahblahblah, blahblahblah, 'blahblahblah', blahblahblah,
I have little unusual problem to solve. I need some hint or links to
I have a little problem about the sort direction of a specific column in
I have a little problem with Jquery getJSON function. my json here { entries:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.