Can you please be more specific. What did not work?
It still outputs as char? This is impossible unless your compiler is so substandard that it simpy shouldn't be used.
It outputs as a decimal number? You forgot to tell output stream to outpun numbers as hexadecimal by using std::hex
Well, the cout was just to see what is actually inside the vector, I want it to be converted to a hex value when it is used as a parameter for GetAsyncKeyState. If I use std::hex on cout it does work for printing, but the the char is still a char when passed on as a parameter. You see GetAsyncKeyState accepts a hex value.
This line: vector <unsignedchar> keyStates (0x1B, 0x49);
creates a vector with 27 (0x1B) elements that all have the decimal value 73 (0x49). Because they are of the type unsignedchar, they are treat as such when calling std::cout. Is this really what you wanted to do?
There is no such thng as hexadecimal value. 20 apples, twenty apples and 0x14 apples is the same amount of apples. Integral values store such abstract numbers. GetAsyncKeyState takes int: an abstract number. It does not matter if you will pass 0x1B, 27 or constant VK_ESCAPE. It is the same thing.
the char is still a char when passed on as a parameter
How did you come to such conclusion? It will be promoted to int as per rules of conversions in C++.
EDIT: your vector might not contain values you expect. Right now it contains 27 (0x1B) copies of 0x49 value (I symbol code). It works fine to detect if I was pressed thought