How to wait for input for a specific amount seconds and move on in C++ (C++ Console)
Then don't use that function anymore, use another function that monitors keys pressed or whatever.
See https://docs.python.org/2/library/msvcrt.html#console-i-o
It's a python documentation page, but the functions are in msvcrt.dll , c++ runtime... see kbhit , getch etc
some of those functions will allow you to get characters and not echo the character on console so you'll have to echo the character yourself.
Also, you'd have to handle the special keys like left right delete ... my advice would be to only accept backspace and enter besides alphanumeric keys and space which should be enough for your needs.
Or you can use API functions like ReadConsoleInput, GetNumberOfConsoleInputEvents to see if there's even some input to handle before calling ReadConsoleInput and so on...
See https://docs.microsoft.com/en-us/windows/console/readconsoleinput
and see Console-Docs/low-level-console-input-functions.md at master · MicrosoftDocs/Console-Docs · GitHub
Store the time or number of milliseconds since the OS started in a variable, print text on console, then go in a loop in which you see if there's a key pressed or not, and update the time or number of milliseconds since OS started and compare the new value with the original value and exit loop if the time expired.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now