The easiest way to get real-time key state on Windows is with GetAsyncKeyState:
1 2 3 4
if(GetAsyncKeyState('A') & 0x8000)
{
// the 'A' key is currently being held down
}
How to do this for all systems (Windows, Linux, Mac,...)?
There is no standard solution that works on all systems. If you want crossplatform support, you'll need an additional library. Libraries like SFML, SDL, wx, Qt, ncurses all have keyboard polling support.
I already searched but only found a Windows solution and something about key-codes, are those 'codes' the same on all systems?
Absolutely not. Every OS works completely differently.
If you want portability across multiple OS's, then you want an external lib like the above mentioned ones. They provide a simplistic interface that works on multiple OS's
Thanks for your awesome reply! :)
And I'm currently about to indeed start working a lot with SFML.
(If I know how to attach the SFML Library to the Geany GUI).
Didn't knew it was possible with that as well.
Thanks a lot man!