Sending WM_KEYDOWN / UP is difficult. The application itself already translates the WM_KEYDOWN message to WM_CHAR using the state of the modifier keys (Shift, Alt, Ctrl) and the keyboard layout. None of which you can control, you accidentally get the wrong character.
Just send WM_CHAR messages, set wparam to character code. No need to worry about lparam, several applications ever use it.
source
share