hi everyone! just started learning c++ a few days ago and have already written 3 or so small programs but i cant seem to find a way around this issue...
basically i want my program to output/register when the user presses something (so it would output [SHIFTon] for example) and then also registers/outputs something when they eventually release the key (so it would then output [SHIFToff])
ive looked around this website along with some other places trying to find a solution for this but either i cant find what im looking for or the solution i find doesn't work/i have no idea how to properly use it.
so does anyone here have any tips or ideas for workign around this? thanks in advance!
C++ is a bare bones language. There is no standard library for getting keyboard events because the program might not be running with a keyboard (i.e. a robot.) Therefor you need to find a third-party library to do this (and their code will use OS functions to do what you need, like for example the Windows API, but don't do that yourself, it's confusing for someone new to programming.)
Usually, you would use the Windows API for such a thing (if you're on Windows). But since your a beginner, I would definitely recommend that you stay away from there.
Don't try and imitate a Win32 application in a console because it just won't work; well, it might, but not that well.
I don't have time to play with it at the moment, but it seems to toggle, don't know if you can stop that and use a 'held down' state or something similar:
ok thanks ill take a look at the link you posted aswell as try the code later tonight when i get a chance. and fyi i am on windows and im using visual 2010 express (idk if the compiler matters for this particualr problem but cant hurt to know right?) sorry i shouldve said that before.
also im workign with (GetAsyncKeyState(VK_SHIFT) == -32767) right now to register when shift is pressed and all aswell as other keys
(im tryign to make a keylogger btw, not for malicious purposes obviously but to keep my annoying friends from messing with my computer while im away from it -_-)