Ok i updated my original getkey function.
Now it returns ascii if you press a character and virtualkeycode if you press something else;
Examples coming soon !
Here is the functions(you need windows.h for it to work)
#include <iostream>
usingnamespace std;
#include <windows.h>
TCHAR GetKey() //returns ASCII code if you press a character(a, ? , * ,j, ~ , and so on), and
{ //returns Virtual key code if you dont press a character( VK_UP(up arrow),VK_LEFT(left arrow),VK_SPACE(space), and so on)
INPUT_RECORD InputRecord;
DWORD Writtten;
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
while(true)
{
ReadConsoleInputA(hStdIn,&InputRecord,1,&Writtten);
if(InputRecord.EventType==KEY_EVENT&&InputRecord.Event.KeyEvent.bKeyDown) break;
}
char ASCII=InputRecord.Event.KeyEvent.uChar.AsciiChar;
if(ASCII) return ASCII;
return InputRecord.Event.KeyEvent.wVirtualKeyCode;
}
int main()
{
char a;
cout<<"Press Control Key to Exit,char 'n' to say Hello World !"<<endl;
while(true)
{
a=GetKey();
if(a==VK_CONTROL) break;
if(a=='n') cout<<"Hello World !\n";
}
cout<<"\nPress any Key to continue . . .\n";
GetKey();
return 0;
}