That code looks kinda....messy. This is more what I did:
In the WndProc switch statement
Code:
case WM_KEYDOWN:
keys[wParam]=TRUE;
return 0;
case WM_KEYUP:
keys[wParam]=FALSE;
return 0;
In the game loop:
Please note, textPos was predefined as an integer variable which indicates the current position in the char array, name is a char array of size 32, and keys is a global array that is modified in the wndproc.
Code:
if(textPos<31)
{
for(int a='A';a<='Z';a++)
{
if(keys[a])
{
keys[a]=false;
name[textPos]=a;
textPos++;
}
}
if(keys[VK_SPACE])
{
keys[VK_SPACE]=false;
name[textPos]=' ';
textPos++;
}
}
if(keys[VK_BACK] && textPos>0)
{
keys[VK_BACK]=false;
textPos--;
name[textPos]=0;
}
So in other words, it might be best just to separate the typing code from the WndProc's code.