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 7715513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:24:15+00:00 2026-06-01T02:24:15+00:00

Hey guys i have a question which i have been looking for the answer

  • 0

Hey guys i have a question which i have been looking for the answer to for quite a while, i have seen many questions alike but none solved my problem.

So i have a function that grabs the players name using get line that goes like this.

std::cout << "Enter your name"<< std::endl;
std::string input;

std::getline(std::cin, input);

and afterwards I have a function that has a menu which tells the user he can press a series of keys to move on to other parts of the menu.

while(true)
{
        //menu one
        if(GetAsyncKeyState(VK_CONTROL))
        {
            Menu_3();
        }
        //here is the problem
        if(GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(0x53)) //0X53 = S
        {
            Menu_4();
        }
}

My problem is that if i use a name with a capital letter(created with SHIFT) and an ‘s’ also Menu_4() gets called automatically after i enter the name, example name “Shawn”. if i only have a name like this “shawn”(without using shift) then that “s” seems to get stored in the cin buffer and all that is required to move on is press “shift” to get into Menu_4();

Basically the input is getting carried over from the getline name request and its screwing up my GetAsyncKeyState() calls.

Thanks for your help.

  • 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-01T02:24:17+00:00Added an answer on June 1, 2026 at 2:24 am

    I think you misunderstood the behavior of GetAsyncKeyState

    see GetAsyncKeyState

    If the function succeeds, the return value specifies whether the key
    was pressed since the last call to GetAsyncKeyState, and whether the
    key is currently up or down. If the most significant bit is set, the
    key is down, and if the least significant bit is set, the key was
    pressed after the previous call to GetAsyncKeyState

    …

    Although the
    least significant bit of the return value indicates whether the key
    has been pressed since the last query, due to the pre-emptive
    multitasking nature of Windows, another application can call
    GetAsyncKeyState and receive the “recently pressed” bit instead of
    your application. The behavior of the least significant bit of the
    return value is retained strictly for compatibility with 16-bit
    Windows applications (which are non-preemptive) and should not be
    relied upon.

    Probably you want to check the current state not if the key was pressed from last call.

    if(GetAsyncKeyState(VK_CONTROL) xor 0x1)
    ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, lately I have been asking quite a few questions about memory management
Hey guys I have a question which is... I want a panel at the
Hey guys I have a question which is how to get information from one
Hey guys, I don't know if this question has been asked yet but imagine
Hey guys I have what should be a simple question, but I am new
Hey guys, this question might be a little weird worded but I was looking
Hey guys I have one more question lol. I am using a script that
Hey guys quick question, I have an entry that I put in my database,
Hey guys quick question, I currently have an insert statement $query= INSERT into new_mail
Hey guys quick question. I have a div that gets assigned a number to

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.