keybd_event() won't use the numpad

I'm trying to get my program to type alt code characters like 'é'. This requires the program to hold alt use the number pad.
I use this to hold alt:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void altKey(bool state)
{
    if(state == true)
    {
        keybd_event( VK_MENU,
                      0x45,
                      KEYEVENTF_EXTENDEDKEY | 0,
                      0 );
    }
    else
    {
        keybd_event( VK_MENU,
                      0x45,
                      KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
                      0);
    }
}


And this to press the keys:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void pressKey(unsigned char key)
{
    {
      // Simulate a key press
         keybd_event( key,
                      0x45,
                      KEYEVENTF_EXTENDEDKEY | 0,
                      0 );

      // Simulate a key release
         keybd_event( key,
                      0x45,
                      KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
                      0);
      }
}


The problem is when ever I call pressKey(VK_NUMPAD0), it uses the number keys that are not on the numpad. What is causing this and how can I fix it?
1
2
3
4
while(state==true)
{
     //Hold alt
}


might work
Topic archived. No new replies allowed.