GetKeyNameText - Is the API or Buggy or is it Me?
Hi there,
I'm trying to convert a virtual key (vk) code into a simple string, but I'm having problems. Here is my code:
Code:
std::string rslt;
unsigned int sc = MapVirtualKey(vk, 0);
sc <<= 16;
char buf[256];
if (GetKeyNameTextA(sc, buf, 256) > 0)
rslt = buf;
It works for some key code values, but there are dozens where it inexplicably returns errorneours values. For example, PAGE_UP returns the string "NUM 9", PAGE_DOWN returns give "NUM 3", DELETE gives "NUM DECIMAL".
I have tried setting bits 24 & 25 of the scan code, but that appears to make things worse.
I read somewhere that GetKeyNameText has a bug where it returns a wrong value for the numeric keypad divide, however in my case, it is not just one character which is wrong.
Am I doing something wrong? Can anyone help?