I got problem when one of my customer complains about they use azerty keyboard and they can't use my product. So I decide to use scan code instead of virtual key. I found the function MapVirtualKey is really useful for me to achieve that. But in some situation, I don't want to use MapVirtualKey function but use the number itself, like {if(isKeyDown[30])return 'A';} but I go around the internet and realize that some source tell that their keyboard scan code is not like mine, like in this image
I don't understand it, why it's different from my keyboard's scan code, and even different from this MS scan code table
So I really wonder, Is it safe to use
if (isDownNow[48])
return 'B';
instead of
if (isDownNow[MapVirtualKey('B', MAPVK_VK_TO_VSC)])
return 'B';
Thank you for reading :)
Edit: I think I have a solution for the problem above, instead of call MapVirtualKey every time, I will store the map in an array. But new problem comes up. I don't have a azerty keyboard so I can't test this, I only have a qwerty keyboard, so I got confuse on this problem: I got this function to store my map.
void MapKeyData()
{
for (int i = 0; i < KEYS_SIZE; i++)//KEYS_SIZE=255
mapKey[i] = MapVirtualKey(i, MAPVK_VK_TO_VSC);//mapKey is unsigned char array
}
But I want the Z in normal keyboard (qwerty keyboard) map with the W in azerty keyboard. But as the function MapKeyData above, I think the Z in qwerty keyboard still map with the Z in azerty keyboard which is definitely not my purpose, I want to keep the keyboard layout, not the key itself. But as I said, I don't know if the scan code is the same on every keyboard as the first picture show that the keycode different from my scan code.
Thank for reading :)