Dead-Character Messages

Windows programs can usually ignore WM_DEADCHAR and WM_SYSDEADCHAR messages. On some non-U.S. keyboards, certain keys are defined to add a diacritic to a letter. These are called ”dead keys“ because they don't create characters by themselves. For instance, when the German keyboard is installed, the key that is in the same position as the +/= key on a U.S. keyboard is a dead key for the acute accent (\a) when unshifted and the grave accent (\g) when shifted.

When a user presses this dead key, your window procedure receives a WM_DEADCHAR message with wParam equal to the ASCII code for the diacritic by itself. When the user then presses a letter key (for instance, the A key), the window procedure receives a WM_CHAR message where wParam is the ASCII code for the letter a with the diacritic. Thus, your program does not have to process the WM_DEADCHAR message, because the WM_CHAR message gives the program all the information it needs. The Windows logic even has built-in error handling: If the dead key is followed by a letter that can't take a diacritic (such as the letter s), then the window procedure receives two WM_CHAR messages in a row—the first with wParam equal to the ASCII code for the diacritic by itself (the same wParam value delivered with the WM_DEADCHAR message) and the second with wParam equal to the ASCII code for the letter s.